Metacharachters

Perl interprets several characters in regular expressions as metacharacters, characters that represent something other than their literal interpretation.

We’ve seen a few metacharacters already (\b, ., and ?, for example). Metacharacters give regex wielders power far beyond mere substring matches. The regex engine treats all metacharacters as atoms. See perldoc perlrebackslash for far more detail about metacharacters.

The . metacharacter

The . metacharacter means “match any character except a newline.” Many novices forget that nuance. A simple regex search—ignoring the obvious improvement of using anchors—for 7 Down might be /l..m/. Of course, there’s always more than one way to get the correct answer:

Get hands-on with 1400+ tech skills courses.