fapapfap Posted December 28, 2011 Share Posted December 28, 2011 The following regex looks for the pattern including </a>. I would like to add in an OR condition which also includes patterns which include </span>, which somestimes is shown in results in place of </a>, is that possible? Regex: $pattern = '~">[^ ]+<\/a>~i'; I thought I could do '~">[^ ]+(<\/a>|<\/span>)~i'; But doesn't work Link to comment https://forums.phpfreaks.com/topic/253953-regex-problem-for-using-an-or-statement/ Share on other sites More sharing options...
jmb272 Posted December 28, 2011 Share Posted December 28, 2011 What about: $pattern = '/(<\/a>)|(<\/span>)/'; Link to comment https://forums.phpfreaks.com/topic/253953-regex-problem-for-using-an-or-statement/#findComment-1301860 Share on other sites More sharing options...
fapapfap Posted December 28, 2011 Author Share Posted December 28, 2011 What about: $pattern = '/(<\/a>)|(<\/span>)/'; Hi thanks for replying but it is slighly more complex because of the full search string: $pattern = '~\<a href="http:\/\/www\.site\.net\/page\.php\?action=p\&uid=[0-9]+">[^ ]+<\/a>~i'; This will successfully extract the TEXT in the following HTML: <a href="http://www.site.net/page.php?action=p&uid=29">TEXT</a> But not instances where the format changes slightly: <a href="http://www.site.net/page.php?action=p&uid=29"><span style="color:#ffcc00">TEXT</span></a> An adjustment to the pattern regex is what I am looking for so to still extract the TEXT given either of these formats (NOTE: THE COLOUR HEX IS VARIABLE!) Link to comment https://forums.phpfreaks.com/topic/253953-regex-problem-for-using-an-or-statement/#findComment-1301866 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.