4 ms·
My favorite feature is: -P, --perl-regexp Interpret I<PATTERNS> as Perl-compatible regular expressions (PCREs). This
by nickcw 5y ago
My favorite feature is:
-P, --perl-regexp
Interpret I<PATTERNS> as Perl-compatible regular
expressions (PCREs). This option is experimental when
combined with the -z (--null-data) option, and grep -P
may warn of unimplemented features.
As everything (python, Go, javascript, etc, etc) uses perl regexps now-a-days and I can never remember which things I need to escape for old gods regexp.
- kjeetgill 5y agoHaha, agreed 100%. My go to for years had been https://www.regexplanet.com/ https://www.regexplanet.com/. It let's you test what regex escapes work where without spinning up one-off `void main()s`.
- hrez 5y agoalso combined with -o i.e. grep -Po "Name:\K\w+"
- silisili 5y agoSlightly pedantic, but Go uses RE2 which is subtly different than PCRE. In most common use cases, you'd probably never know.