Get the latest tech news

Is there a regular expression to detect a valid regular expression? (2008)


Is it possible to detect a valid regular expression with another regular expression? If so please give example code below.

It is possible if the regex engine supports recursion, such as PCRE, but that can't really be called regular expressions any more. I am making a script that could grep a code base to find all the files that contain regular expressions Some modern implementations allow recursion, which makes it into a Context Free language, although it is somewhat verbose for this task.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of regular expression

regular expression