|Perl Language Reference Manual|
by Larry Wall and others
Paperback (6"x9"), 724 pages
RRP £29.95 ($39.95)
Sales of this book support The Perl Foundation! Get a printed copy>>>
13.3 Bracketed Character Classes
The third form of character class you can use in Perl regular expressions
is the bracketed form. In its simplest form, it lists the characters
that may be matched, surrounded by square brackets, like this:
This matches one of
u. Like the other
character classes, exactly one character will be matched. To match
a longer string consisting of characters mentioned in the character
class, follow the character class with a quantifier. For instance,
[aeiou]+ matches a string of one or more lowercase ASCII vowels.
Repeating a character in a character class has no effect; it's considered to be in the set only once.
"e" =~ /[aeiou]/ # Match, as "e" is listed in the class. "p" =~ /[aeiou]/ # No match, "p" is not listed in the class. "ae" =~ /^[aeiou]$/ # No match, a character class only matches # a single character. "ae" =~ /^[aeiou]+$/ # Match, due to the quantifier.
|ISBN 9781906966027||Perl Language Reference Manual||See the print edition|