jamesmiller Posted September 16, 2011 Share Posted September 16, 2011 hey guys. sorry if this is a simple question and easy to do but i need a regex to pick out Author: anything can be here </h3> from <h3> <span class="author"> Author: </span> <span> <a href="/catalog/list_author_titles?author=John+search=search">John </a> </span> Thank you for any help, Quote Link to comment https://forums.phpfreaks.com/topic/247267-easy-regex-question/ Share on other sites More sharing options...
AyKay47 Posted September 16, 2011 Share Posted September 16, 2011 <?php $string = "<h3> <span class='author'> Author: </span> <span> <a href='/catalog/list_author_titles?author=John+search=search'>John </a> </span></h3>"; $pattern = "~Author: .*~i"; preg_match($pattern,$string,$matches); foreach($matches as $match){ print $match . "<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/247267-easy-regex-question/#findComment-1269887 Share on other sites More sharing options...
salathe Posted September 16, 2011 Share Posted September 16, 2011 There's no </h3> in your "from" code. Quote Link to comment https://forums.phpfreaks.com/topic/247267-easy-regex-question/#findComment-1269891 Share on other sites More sharing options...
jamesmiller Posted September 16, 2011 Author Share Posted September 16, 2011 My apologies I was meant to put it on the end but forgot thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/247267-easy-regex-question/#findComment-1269896 Share on other sites More sharing options...
xyph Posted September 16, 2011 Share Posted September 16, 2011 I think it's about time you purchased a RegEx book Quote Link to comment https://forums.phpfreaks.com/topic/247267-easy-regex-question/#findComment-1270026 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.