Tregexp class
(Translation: Yunhai Update Date: November 1, 2004 E-mail: Yun_Hai@hotmial.com)
Tregexp class
Contain files
description
This is a regular expression class. TREGEXP is a class that is used as a string search.
Regular expressions use these special characters:. [] - ^ *? $
General rules:
In addition to special characters, characters match them themselves. For example, "Yardbird" matches "Yardbird".
A special character with a backslash (/) followed, matching special characters it itself. For example, "pardon /?" Matches "pardon?"
The following escape code may be used to match control characters:
/ B
Backspace
/ e
ESC (canceled)
/ f
FormFeed
/ N
NEWLINE (new row)
/ r
Carriage returna (Enter)
/ t
Tab (Table)
/ xddd
This is a hexadecimal value 0xDDD
/ ^ x
X Match some control code (for example / ^ c, / ^ c)
Single character regular expression:
"." Match any character and special characters other than / n. For example, ".ive" matches "jive" or "FIVE". "[" "]" Matches any of the characters contained. For example, "[aeiou]" will also match "a", "e", "i", "o" or "u". Special characters are used in [], match any characters within the specified range. For example, "[A-Z]" will match any lowercase letters between A and Z.
"^" Matches the unconnected character. For example, "[^ g-V]" does not match any lowercase letters between G-V. For example, "[^ g- v]". Will match any lowercase letters between G and V.
Multi-character regular expression:
"*" Matches the previous sub-expression zero or multiple times. For example, "[A-Z] *" matches the expression of the letter started zero or multiple times
" " Matches the previous sub-expression once or more. For example, "[0-9] " matches characters starting with the number.
"?" Match zero or once in front of the child expression. For example, "XY" Z "matches" XY "or" XYZ ".
Regular expression combination
For example, "[A-Z] [A-Z] *" matches the word starting with uppercase letters.
Match from the beginning of the start to the end of the wrap.
If the regular expression is started in ^, the start position of the input string is matched. For example, "^ [A-Z] [A-Z] *" matches the row starting with uppercase letters.
If the regular expression is ended, the $ matching the end position of the input string. For example, "[A-Z] [A-Z] * $" matches the end of the word starting with uppercase letters.
Statval
grammar:
Enum statval {ok = 0, Illegal, Toolong};
description
Starval enumeration is returned by Tregexp :: status
status
description
OK
It means that a given regular expression is legal
Illegal
It is illegal to the law
Toolong
It is more than the maximum length (128)
Public constructor
Form 1:
TregEXP (Const Char Far * CP);
Form 2:
TregeXP (Const Tregexp Far & R); Description:
Form 1:
Constructs a regular expression object that uses CP as a regular expression.
Form 2:
Constructs the regular expression object replication object R.
Public member function
Find
grammar:
SIZE_T FIND (const string & s, size_t * len, size_t start = 0)
description:
Find a string that matches the regular expression in a string. Search Starting from Start, the length of the Len returns a matching string. Returns the start position of the matching string. If no match is found, LEN is 0 and returns -1.
STATUS
grammar:
Statval status ()
description:
Returns the status of this regular expression.
The status value is:
status
description
OK
It means that a given regular expression is legal
Illegal
It is illegal to the law
Toolong
It is more than the maximum length (128)
Operator
=
Form 1:
TregeXP & Operator = (const tregexp & r)
Form 2:
TregeXP & Operator = (const char * cp)
description:
Form 1:
Copy the regular expression object instance R to the current regular expression instance.
Form 2:
Set the regular expression of a regular expression object to a CP.