Character with Class

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email

Regular expressions can also match on character classes, which are lists of single characters to be matched. To specify a character class, you use square brackets and list the characters. For example, you have already seen how to use alternation to match "x' or W:

if ($Test = / (xlX)/) ...

To do the same thing With a character class, you would use

if($Test =~ /[xX]/) ...

You can use the caret character (A) in front of a list to indicate that you want to match any character not in that range. For example, to indicate any character that is not one of the first five capital letters, you would use

if ($Test =~ / [^ABCDE]/) .

Character classes can be specified as range using a hyphen H. Thus, the "any digit" example can be simplified even more:

if ($Test =- /[0-91/) . . .

Because these ranges are so commonly used in Perl, you can use a couple of shortcuts so that you don't have to specify the actual range. These shortcuts are like the backslash codes used for special characters (like\t for tab character), except that they indicate a range to be matched.



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.