October 21st, 2014

The great thing about regular expression languages is that there are so many to choose from!

Before you ask a question about regular expressions, you should make sure you and your audience agree on which regular expression language you are talking about.

Here is a handy table of which features are supported by which regular expression language.

You can use that table to solve this customer’s problem:

I have a regular expression that works just fine when I test it in ⟨insert regular expression testing tool, like RegExr or RegexPlanet⟩, but I can’t get it to work in real life.

C:\> findstr /r /c:"a(?!.*b)" file.txt
(prints no results!)
C:\>

My goal is to find all lines that contain an a not followed anywhere by a b.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.