Regular Expression Help


The following match as stated:

 . any single character
 $ end of a line
\< start of a word
\b either edge of a word
[asd] a, s or d
[^a-zA-Z] Anything except a letter (the ^ negates)
 ^ beginning of a line
\> end of a word
\B empty string not at the edge of a word
[a-d 0-9] abcd0123456789 or space



Repetition Operators:

? The preceding item will be matched zero or one times
* The preceding item will be matched zero or more times
+ The preceding item will be matched one or more times
{n} The preceding item will be matched exactly n times
{n,} The preceding item will be matched n or more times
{n,m} The preceding item will be matched from n to m times



Shortcuts:

[:alpha:]  [:lower:]  [:upper:]  [:digit:]  [:alnum:]  [:punct:]  [:blank:]  [:cntrl:]  [:graph:]  [:print:]  [:space:]  [:xdigit:]

[:blank:] means space or tab.  [:space:] means space tab CR FF NL or VT
[:print:]  means  [:alnum:], [:punct:] or [:space:]
[:xdigit:] means a hexadecimal digit, i.e. [0-9A-Fa-f]

Note that these shortcuts still need to be in brackets. Yes, really! e.g. [[:punct:]e] matches punctuation or 'e'

\w is a synonym for [[:alnum:]]     \W is a synonym for [^[:alnum]]
( ) do their usual precedence thing.  | is the OR operator  e.g. d(i|o)g matches dig or dog


For less concise information, including about backreferences, see man grep. If then you are still insufficiently confused, try man 7 regex.