Game Development Reference
In-Depth Information
Character Class
A character class is used to represent a set of characters and can be any of the following:
x : Represents the character x itself, not one of the magic characters ^ , $ , () , % , . ,
[ , ] , * , + , , or ?
. : Functions in same way as the wildcard that represents all characters
%a : Represents all letters
%c : Represents all control characters
%d : Represents all digits
%l : Represents all letters (lowercase)
%p : Represents all punctuation characters
%s : Represents all space characters
%u : Represents all uppercase characters
%w : Represents all alphanumeric characters
%x : Represents all hexadecimal characters
%z : Represents the character with the representation 0
% x : Allows you to escape any magic character (note that x is not the literal
character x , but any nonalphanumeric character)
[ set ] : Represents a union of all characters in set . The range of characters can
be specified with a hyphen (−), as in [0-9] or [a-z] .
[^ set ] : Represents the complement of set . So, [^0-9] would mean all
characters that are not in the range 0 to 9.
For all classes that are represented by a single letter (e.g., %a , %c , %s , and so on), the corresponding
uppercase letter represents the complement of the class. So, %S represents all non-space characters.
Pattern Item
A pattern item is a single character class that matches any single character in the class.
There are a few characters that help quantify the matches:
* : This matches zero or more repetitions of characters in the class. This will
always return the longest possible sequence.
+ : This matches one or more repetitions of characters in the class. This will
return the longest possible sequence.
: This also matches zero or more repetitions of characters in the class, but
unlike * , this will match the shortest possible sequence.
? : This will match zero or one occurrence of a character in the class.
 
Search WWH ::




Custom Search