Expert Refresh


1) Which one matches in Perl a word boundary?

2) Find any whitespace character

Backspace \b
In Perl regex, \b normaly matches a word boundary, but withing a character class it matches a backspace.
Generic whitespace \s
Many regex flavors provide a useful shorthand \s. Is a shorthand for a whole character class that matches any "whitespace character". This includes space, tab, newline, and carriage return.
The add i in m/../i instructs Perl to do the match in a case-insensitive manner. It's not acctualy part of the regex, but part of the m/../ syntatic packaging.
Among the more useful shorthand that Perl provide are: \t a tab character \n a newline character \r a carriage-return character \s any "whitespace" character (space, tab, newline) \S anything not s \w [a-zA-Z0-9_]+ match a word with w+ \W [^a-zA-Z0-9_]+ anything not w \d [0-9] a digit \D [^0-9] anything not d