Regex helper
categories: Uncategorized
I recently had to come up with a regular expression that I could run against an HTML string that would only affect content, not tags or attribute values. I'm no regex master, so after a whole lot of failed attempts, I turned to the Google and found this invaluable regex tester, which also had a bunch of other problems already solved (click on the Samples link at the top). Here's the answer to my particular question that day:
/(?![^<]+>)\b(text_to_match)\b/
I hate when it's that simple.
January 28th, 2008 at 11:16 pm
Glad you like my regex tester, I’ve delayed improving it, but soon there will be vast improvements.
Viva la Web.
April 8th, 2008 at 9:01 am
Invaluable indeed. Thanks!