

\s matches any single character considered whitespace. Īny character not matched by \w is matched by \W. \N Match a character that isn't a newline. \V Match a character that isn't vertical whitespace. \v Match a vertical whitespace character. \H Match a character that isn't horizontal whitespace. \h Match a horizontal whitespace character. (For the backslash sequences that aren't character classes, see perlrebackslash.) \d Match a decimal digit character. Here's a list of the backslash sequences that are character classes. That is, they match a single character each, provided that the character belongs to the specific set of characters defined by the sequence. Perl ascribes special meaning to many such sequences, and some of these are character classes. "ab" =~ /^.$/ # No match (dot matches one character) # Backslash sequencesĪ backslash sequence is a sequence of characters, the first one of which is a backslash.

"\n" =~ /(?s.)/ # Match (local 'single line' modifier) "\n" =~ /./s # Match (global 'single line' modifier) "\n" =~ /./ # No match (dot does not match a newline) "" =~ /./ # No match (dot has to match a character) Here are some examples: "a" =~ /./ # Match (The "\N" backslash sequence, described below, matches any character except newline without regard to the single line modifier.) That default can be changed to add matching the newline by using the single line modifier: for the entire regular expression with the /s modifier, or locally with (?s) (and even globally within the scope of use re '/s'). By default, a dot matches any character, except for the newline. is probably the most used, and certainly the most well-known character class. Certainly, most Perl documentation does that. Keep in mind, though, that often the term "character class" is used to mean just the bracketed form. There are three types of character classes in Perl regular expressions: the dot, backslash sequences, and the form enclosed in square brackets. (The source string is the string the regular expression is matched against.) It's important to remember that: matching a character class consumes exactly one character in the source string.
REGEX NOT CHARACTER MANUAL
This manual page discusses the syntax and use of character classes in Perl regular expressions.Ī character class is a way of denoting a set of characters in such a way that one character of the set is matched. The top level documentation about Perl regular expressions is found in perlre. Perlrecharclass - Perl Regular Expression Character Classes #DESCRIPTION
