Negative Lookahead Regular Expression

The following regular expression employs the regex lookaround syntax. Specifically, according to terms I learned through the author of Regex Buddy, the following is an example of a Negative Lookahead regular expression.

I intend to revise the illustrative text portion of this post, when I have more time. I apologize for publishing it in such a bare-bones state, but as with so many drafts I have on back order, it must certainly be better to have something of it published, rather than let it sit dormant, never to be read by you or I. That said, please return to this any time you wish, knowing it should be updated.

The following match expression finds each instance of a less-than symbol which is NOT followed by the texts between the “or” operators (i.e. pre|html|head|etc…). This regex syntax features a negative lookahead expression. For the complete definition of lookarounds, and negative and positive lookahead regex, I recommend the regular expressions resources available at Regular-Expressions.Info


Note: other programmers, instructors, etc., may refer to this syntax by various names, other than “lookaround”, or “lookahead”. Please offer your comments, if you are aware of different terms for this syntax, or if you’d like to offer your own examples, or if you just want to write a comment, or…

Leave a Reply

Your email address will not be published. Required fields are marked *