Different tools implement regular expressions differently. For example to match "foo" or "bar":
printf "%s\n" foo bar baz food | grep -o '\<\(fo\+\|bar\)\>'
printf "%s\n" foo bar baz food | awk '/\<(fo+|bar)\>/'
printf "%s\n" foo bar baz food | sed -n '/\<\(fo\+\|bar\)\>/p'
printf "%s\n" foo bar baz food | sed -nr '/\<(fo+|bar)\>/p'
Where are these differences documented?
There are also two types of regular expressions: the "Basic" regular expression, and the "extended" regular expression.
5.2 Basic (BRE) and extended (ERE) regular expression In GNU sed , the only difference between basic and extended regular expressions is in the behavior of a few special characters: ' ? ', ' + ', parentheses, braces (' {} '), and ' | '.
Writing a regular expression pattern. A regular expression pattern is composed of simple characters, such as /abc/ , or a combination of simple and special characters, such as /ab*c/ or /Chapter (\d+)\.\d*/ . The last example includes parentheses, which are used as a memory device.
Python offers two different primitive operations based on regular expressions: match checks for a match only at the beginning of the string, while search checks for a match anywhere in the string (this is what Perl does by default).
Score! I'm so happy to have found this page:
https://www.gnu.org/software/gnulib/manual/html_node/Regular-expression-syntaxes.html
14.8 Regular expression syntaxes
Gnulib supports many different types of regular expressions; although the underlying features are the same or identical, the syntax used varies. The descriptions given here for the different types are generated automatically.
- awk regular expression syntax
- egrep regular expression syntax
- ed regular expression syntax
- emacs regular expression syntax
- gnu-awk regular expression syntax
- grep regular expression syntax
- posix-awk regular expression syntax
- posix-basic regular expression syntax
- posix-egrep regular expression syntax
- posix-extended regular expression syntax
- posix-minimal-basic regular expression syntax
- sed regular expression syntax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With