More metacharacters

Here are some more advanced metacharacters, which build on the ones already covered in the Introduction to Perl module:

Table 3-1. More metacharacters

Metacharacter Meaning
\BMatch anything other than a word boundary
\cXControl character, i.e. CTRL-X
\0nnOctal character represented by nn
\xnnHexadecimal character represented by nn
\lLowercase next character
\uUppercase next character
\L Lowercase until \E
\UUppercase until \E
\Qquote (disable) metacharacters until \E
\EEnd of lowercase/uppercase

# search for the C++ computer language:

/C++/        # wrong! regexp engine complains about the plus signs
/C\+\+/      # this works
/C\Q++\E/    # this works too

# search for "bell" control characters, eg CTRL-G

/\cG/        # this is one way
/\007/       # this is another -- CTRL-G is octal 07
/\x07/       # here it is as a hex code