8d872ae8f8
libregex is a regex(3) implementation intended to feature GNU extensions and any other non-POSIX compliant extensions that are deemed worthy. These extensions are separated out into a separate library for the sake of not cluttering up libc further with them as well as not deteriorating the speed (or lack thereof) of the libc implementation. libregex is implemented as a build of the libc implementation with LIBREGEX defined to distinguish this from a libc build. The reasons for implementation like this are two-fold: 1.) Maintenance- This reduces the overhead induced by adding yet another regex implementation to base. 2.) Ease of use- Flipping on GNU extensions will be as simple as linking against libregex, and POSIX-compliant compilations can be guaranteed with a REG_POSIX cflag that should be ignored by libc/regex and disables extensions in libregex. It is also easier to keep REG_POSIX sane and POSIX pure when implemented in this fashion. Tests are added for future functionality, but left disconnected for the time being while other testing is done. Reviewed by: cem (previous version) Differential Revision: https://reviews.freebsd.org/D12934
31 lines
655 B
Plaintext
31 lines
655 B
Plaintext
# BRE Quantifiers
|
|
ab\?c b abc abc
|
|
ab\+c b abc abc
|
|
# BRE Branching
|
|
abc\|de b abc abc
|
|
a\|b\|c b abc a
|
|
\(ab\|bc\) b abcd ab
|
|
# ERE Backrefs
|
|
(ab)\1 - ab
|
|
(ab)\1 - abab abab
|
|
\1(ab) C ESUBREG
|
|
(a)(b)(c)(d)(e)(f)(g)(h)(i)\9 - abcdefghii abcdefghii
|
|
# \w, \W, \s, \S (alnum, ^alnum, space, ^space)
|
|
\w+ - -%@a0X- a0X
|
|
\w\+ b -%@a0X- a0X
|
|
\s+ - aSNTb SNT
|
|
\s\+ b aSNTb SNT
|
|
# Word boundaries (\b, \B, \<, \>, \`, \')
|
|
# (is/not boundary, start/end word, start/end subject string)
|
|
\babc\b & <abc> abc
|
|
\<abc\> & <abc> abc
|
|
\Babc\B & abc
|
|
\B[abc]\B & <abc> b
|
|
\B[abc]+ - <abc> bc
|
|
\B[abc]\+ b <abc> bc
|
|
\`abc\' & abc abc
|
|
\`.+\' - abNc abNc
|
|
\`.\+\' b abNc abNc
|
|
(\`a) - Na
|
|
(a\') - aN
|