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 Quote Link to comment Share on other sites More sharing options...
jmb272 Posted December 28, 2011 Share Posted December 28, 2011 What about: $pattern = '/(<\/a>)|(<\/span>)/'; Quote Link to comment 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!) Quote Link to comment 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.