troubleshooting Question

Regular Expression Needed For finding words but not words inside HTML

Avatar of Xponex
Xponex asked on
Web DevelopmentASPRegular Expressions
4 Comments1 Solution213 ViewsLast Modified:
I have a regular expression that simply replaces a given word with the the same word surrounded by a SPAN tag to highlight it, like this:

oRegExp.Pattern = "(" & aSearch(nTerm) & ")"
sArticle = oRegExp.Replace(sArticle,"<span style=""background-color:#FFFF00"">$1</span>")

The problem is, if someone searches for something that is within an HTML tag, like if they search for SPAN, then it busts up the HTML. So... I need a new regular expression that only finds the keywords if they NOT with < > tags.

Am I wanting too must from a regular expression? Should I do this some other way that would be more efficient?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros