Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't there a regular expression standard?

I know there is the perl regex that is sort of a minor de facto standard, but why hasn't anyone come up with a universal set of standard symbols, syntax and behaviors?

like image 735
weiy Avatar asked May 10 '10 21:05

weiy


People also ask

Is there a regex standard?

Standard Regular Expression Strings. Regular expressions (RegEx) are a powerful way of matching a sequence of simple characters. You can use regular expressions in Forcepoint Email Security Cloud to create dictionary entries for lexical rules (see Filtering using lexical rules).

Why are regular expressions so complicated?

Density. Regular expressions are dense. This makes them hard to read, but not in proportion to the information they carry. Certainly 100 characters of regular expression syntax is harder to read than 100 consecutive characters of ordinary prose or 100 characters of C code.

Why is regex so unreadable?

The unwarranted use of regular expressions can lead to unreadable expressions. Regular expressions need not be encoded as strings. If you have a library or a tool that can help you build and compose regular expressions, you'll avoid a lot of potential bugs related to string manipulations.


2 Answers

There is a standard by IEEE associated with the POSIX effort. The real question is "why doesn't everyone follow it"? The answer is probably that it is not quite as complex as PCRE (Perl Compatible Regular Expression) with respect to greedy matching and what not.

like image 139
D.Shawley Avatar answered Sep 20 '22 15:09

D.Shawley


Actually, there is a regular expression standard (POSIX), but it's crappy. So people extend their RE engine to fit the needs of their application. PCRE (Perl-compatible regular expressions) is a pseudo-standard for regular expressions that are compatible with Perl's RE engine. This is particularly relevant because you can embed Perl's engine into other applications.

like image 34
tylerl Avatar answered Sep 21 '22 15:09

tylerl