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 |
---|---|
\B | Match anything other than a word boundary |
\cX | Control character, i.e. CTRL-X |
\0nn | Octal character represented by nn |
\xnn | Hexadecimal character represented by nn |
\l | Lowercase next character |
\u | Uppercase next character |
\L | Lowercase until \E |
\U | Uppercase until \E |
\Q | quote (disable) metacharacters until \E |
\E | End 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 |