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, 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 />"; } ?> 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. 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 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 Link to comment https://forums.phpfreaks.com/topic/247267-easy-regex-question/#findComment-1270026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.