Home Linux Utils
Positions:

^     beginning of line
$     end of line
\b    word boundary
\B    a non word boundary


Single Characters:

.     any one character
\d    any digit from 0 to 9
\w    any word character (a-z,A-Z,0-9)
\W    any non-word character
\s    any whitespace character (tab, new line, form feed, end of line, carriage return)
\S    any non whitespace character


Quantifiers (refer to the character that precedes it):

?     appearing once or not at all
*     appearing zero or more times
+     appearing one or more times
{min,max} appearing within the specified range


contains 4 letters

[[a-z]]{4}


line starts with a number

^[[0-9]]


line does not start with a number

[[^0-9]]


Not a vowel

[[^aeiou]]


Defines a marked subexpression. The string matched within the parentheses can be recalled later 


\( \)

example: 
ifconfig  | sed -n 's/.*dr:\(.*\) Bc.*/\1/p'


Match any character except : return or newline

[[^:\r\n]]*


example with sed to change the encrypted password in /etc/shadow

perl -pi -w -e 's/^myuser:[[^:\r\n]]*:/myuser:encryptedPassword:/' /etc/shadow