Regular expression that matches regular expressions

Has anyone ever tried to describe a regular expression that matches regular expressions?

This question is almost impossible to find on the Internet due to duplicate keywords.

It is probably not applicable in real applications, because languages ​​that support regular expressions usually have a method for parsing them, which we can use for testing, and a method for distinguishing regular expressions in code that can be used for searching.

But still, I wonder what the regular expression looks like, matching all regular expressions. It should be possible to write one.

+4
source share
2 answers

, , . , .

? , , , , Lisp ( , HTML) :

, (.. ) , . p , , y . y, , , .

, , , :

, , ^(IMG(\d+))\.png$.

, .

Edit:

¹tomp , PCRE (, , ) - , , ! . , , !

(, " " . , , . CS , , !)

, .

, , , . . - [^@]+@[^@]+, " , ".

RFC 822. ? . , , .

, .

+3

, ... , .

^([igsmx]{1,})?\/(?=.*?(\\w|\\d|\[.*?\]|\(.*?\))).*?\/([igsmx]{1,})?$

, looooooot...

+1

Source: https://habr.com/ru/post/1537141/


All Articles