\d one digit from 0 to 9
\D One character that is not a digit
\w one word character - alphanumeric (letters, numbers, regardless of case) plus underscore (_)
\W One character that is not a word character
\s whitespace character - space, tab, newline, carriage return
\S One character that is not a whitespace character
Quantifiers
. any character
+ One or more
* Zero or more
{3} Exactly three times \D{3} ABC
{2,4} Two to four times \d{2,4} 156
{3,} Three or more times \w{3,} regex_tutorial
? Once or none plurals? plural
\t tab
\n new line
Anchors and Boundaries
^ Start of string or start of line
$ End of string or end of line
\b Word boundary
\B Not a word boundary
Note:- Use "\A and \z" instead of "^ and $" for a string containing a new-line example \n
Note:- Use the pipe to search for two or more expressions in a line of text. For example 'needed' and 'wanted' below
if($line =~ /\b(need|want)ed\b/g)
Note:- [^] means not the characters in the brackets - so [^\w\s] means not word characters and not white space. For example below
if($line =~ s/[^\w\s]//ig)