pcre
Last updated
Last updated
Perl Compatible Regular Expressions (or pcre) are not supported by grep
. There is a pcregrep
that supports it, but traditional grep
on either FreeBSD or Linux lacks support.
This table compares single-letter pcre character class to POSIX names:
Word boundary support:
awk
can use (^|[^_[:alnum:]]|$)
grep
can use \(^\|[^_[:alnum:]]\|$\)
or \(\<\|\>\)
egrep
and grep -E
can use (^|[^_[:alnum:]]|$)
or (\<|\>)
In pcre, the word boundary test (\b
) works for either the left- or right-side of a word. This is different than the \<
and \>
word boundary sequences supported by grep
which have to be used on the appropriate side of a word. This chapter focuses on pcre \b
word bounding for awk
. For information on \<
and \>
support for awk
, see the previous chapter.
Single-letter pcre support can be implemented in awk
for all platforms using:
Description
POSIX
PCRE Single-Letter
Word boundaries
See below list for support
\b
Digits (0-9)
[[:digit:]]
or [0-9]
\d
Non-Digits
[^[:digit:]]
or [^0-9]
\D
Whitespace characters
[[:space:]]
or [ \t\r\n\v\f]
\s
Non-whitespace characters
[^[:space:]]
or [^ \t\r\n\v\f]
\S
Alpha-numeric and underscore
[[:alnum:]_]
or [A-Za-z0-9_]
\w
Non-word characters
[^[:alnum:]_]
or [^A-Za-z0-9_]
\W