September 2017
Beginner
402 pages
9h 52m
English
We have already seen an example of such a class—\s for matching a space character. Its uppercase-counterpart, \S, does the opposite—it matches with any character except a space. Let us examine an example:
my $str = 'Hello, World!';say 'OK' if $str ~~ / \s World /; # OKsay 'OK' if $str ~~ / Hello\S /; # OK
Both regexes match. The \s in the first one matches with the space between words. The \S in the second example matches with a comma.
The character class \s is a combination of other whitespace character classes—\h and \v, which are described in the following sections. These classes also include individual characters such as \t (horizontal tabulation, 0x09) or \r (line feed, 0x0A).
Read now
Unlock full access