4 ms·
POSIX specifies two flavours of regular expressions: basic regular expressions (BRE) and extended regular expressions (ERE). There are subtle differences betwe
by susam 3y ago
POSIX specifies two flavours of regular expressions: basic regular expressions (BRE) and extended regular expressions (ERE). There are subtle differences between the two and ERE supports more features than BRE. For example, what is written as a\(bc\)\{3\}d in BRE is written as a(bc){3}d in ERE. See https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1... for more details.
The regular expression engines available in most mainstream languages go well beyond what is specified in POSIX though. An interesting example is named capturing group in Python, e.g., (?P<token>f[o]+).
- tankenmate 3y agoIndeed, and the most common is Perl since it was the source of many of the extensions.
- rusk 3y agoI would hazard that nowadays it’s Java due to its broad permeation of the application space
- jwilk 3y ago> what is written as \(f..\)\1 in BRE is written as (f..)\1 in ERE Oddly, there are no backreferences in POSIX EREs.
- susam 3y agoYou are right indeed. Looked at the specification again and indeed there is no back-reference in POSIX ERE. Quoting from <https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/xrat/V4_xbd_chap09.html https://pubs.opengroup.org/onlinepubs/9699919799.2008edition...>: > It was suggested that, in addition to interval expressions, back-references ( '\n' ) should also be added to EREs. This was rejected by the standard developers as likely to decrease consensus. Updated my comment to present a better example that avoids back-references. Thanks!
- GrumpySloth 3y agoThat’s because POSIX EREs are actual regular expressions thank god.
- deleted 3y ago[deleted]