Files

5.7 KiB

regular expressions

What regular expression do tools use?

tool regular expression type
awk extended posix
csplit basic posix
dbx basic posix
dbxtool basic posix
ed basic posix
egrep extended posix
emacs emacs regular expression
expr basic posix
grep basic posix
lex basic posix
more basic posix
nawk extended posix
nl basic posix
perl perl regular expression
pg basic posix
rdist basic posix
sed basic posix
ugrep extended posix
vi basic posix

basic posix regular expression

..

(extended) posix regular expression

+---------------+-----------+---------------+---------------------------+ | character | class | type | description | +:==============+:==========+:==============+:==========================+ | . | all | character set | match any character | | | | | (except newline) | +---------------+-----------+---------------+---------------------------+ | ^ | all | anchor | start of line | +---------------+-----------+---------------+---------------------------+ | $ | all | anchor | end of line | +---------------+-----------+---------------+---------------------------+ | [...] | all | character set | list/range of characters | +---------------+-----------+---------------+---------------------------+ | * | all | quantifier | zero or more occurences | +---------------+-----------+---------------+---------------------------+ | \< | all | anchor | start of word | +---------------+-----------+---------------+---------------------------+ | \> | all | anchor | end of word | +---------------+-----------+---------------+---------------------------+ | \(..\) | all | backreference | remember pattern for | | | | | referencing (positional) | +---------------+-----------+---------------+---------------------------+ | \1..\9 | all | reference | reference to numbered | | | | | pattern (positional) | +---------------+-----------+---------------+---------------------------+ +---------------+-----------+---------------+---------------------------+ | + | extended | quantifier | one or more occurences | +---------------+-----------+---------------+---------------------------+ | ? | extended | quantifier | zero or one occurence | +---------------+-----------+---------------+---------------------------+ | \{M,N\} | extended | quantifier | M to N occurences | +---------------+-----------+---------------+---------------------------+ | (...|...) | extended | pattern | match multiple patterns | +---------------+-----------+---------------+---------------------------+

posix character sets

+-------------------+---------------------------------------------------+ | character set | description | +-------------------+---------------------------------------------------+ | [:alnum:] | alphanumeric characters | +-------------------+---------------------------------------------------+ | [:ascii:] | ascii characters | +-------------------+---------------------------------------------------+ | [:cntrl:] | control characters (0x00..0x1F, 0x7F) | +-------------------+---------------------------------------------------+ | [:lower:] | lower case letters | +-------------------+---------------------------------------------------+ | [:upper:] | upper case letters | +-------------------+---------------------------------------------------+ | [:space:] | whitespace characters including line breaks | +-------------------+---------------------------------------------------+ | [:alpha:] | letters | +-------------------+---------------------------------------------------+ | [:digit:] | digits | +-------------------+---------------------------------------------------+ | [:print:] | printable characters, anything except control | | | characters | +-------------------+---------------------------------------------------+ | [:blank:] | space and tabulator | +-------------------+---------------------------------------------------+ | [:graph:] | visible characters, anything except control | | | characters and whitespace | +-------------------+---------------------------------------------------+ | [:punct:] | punctuation characters (and symbols) | +-------------------+---------------------------------------------------+ | [:xdigit:] | hexadecimal digits | +-------------------+---------------------------------------------------+