If I use Perl regex (PCRE) with GNU grep
, it works pretty well; please consider:
$ echo FOO | grep -P '(?i)foo'
FOO
I tried PCRE with awk
but awk
does not support PCRE.
I only found three different regex modifiers for awk
/gawk
--posix
--traditional
--re-interval
Does any of the awk
family use Perl regex (PCRE) like the grep -P
example above?
No, awk does not support Perl REs. One of the primary tenets of the awk language is to keep the language small by not providing constructs to do simple things a bit more briefly. That's how they avoid the language bloat and associated complexity that perl suffers from (see http://www.zoitz.com/archives/13 for the common perception of perl readability). In this case while some of the Perl RE syntax lets you do some things a bit briefer, you don't NEED special language constructs to do them as there's other ways to do whatever you want with existing constructs (maybe not in one RE or using one function so not as briefly) so awk doesn't support them.
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