php - Regexp all but omit attributes containing data -


for example have text:

bla bla 1 2 3 <b> test romans 12:5 </b> okay next line , next text romans 12:5 , text important romans 12:5 <іmg src="/іmg.png" title="romans 12:5" alt="romans 12:5" someattr="romans 12:5" /> <a title="romans 12:5" href="/link.html">romans 12:5</a> 

i need catch:

romans 12:5 

but regexp must omit text placed on attributes (alt,title,anyone) , omit text placed in <a> tags too.

i have similar regexp catches including atributes containing text:

romans(\?| |\.|\. |\.\r\n|\r\n)([0-9]{1,3}):([0-9]{1,3}) 

btw use php preg_replace regexp , text modifies this:

<a href=\"http://site.com/romans/\\7\\3#\\4\" target=\"romans 12:5\">\\1</a> 

who know modernized way this?

thanks in advance!

[^">]{1}(romans \d{1,3}:\d{1,3})[^"<]{1} 

matches 3 instances of romans 12:5 outside attributes , <a> tag.

edit: in order match additional requirements, can use this:

(?:[^">]|^){1}(romans \d{1,3}:\d{1,3})(?:[^"<]|$){1} 

if still doesn't fit need, regexlib.com has wealth of regular expressions kinds of scenarios can adapt suit needs, such this one.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -