regex - ASP.NET regular expression -


i have following regex

(?<!<[title|h1|a][^>]*>[^<]*)(?<!<[meta|img][^>]*[^/>])(someword) 

i using above replace words url. i.e.

the new product x 

will become

the new <a href="/productx">product x</a> 

its working expected. doing negative behind don't replace things in tilte, h1 , anchor tags. need extend if there bold tag within anchor tag not match.i.e.

<a href="/something">the new <b>product x</b></a> 

should not replaced. way have negative lookbehind finds bold tag , matches. want skip if inside . interested need search page returns results

<a href="/something"><b>searchterm</b> other text</a> 

any appreciated

the short answer can't write good, single regular expression want. there special cases cause false positives. there better ways want. being said, if you're still going regex solution, might closer want:

(?<!<(?:title|h1|a)[^>]*>(?:[^<]|<[^/]|</(?!title|h1|a))*|<[meta|img][^>]*)(someword) 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -