- Using the Backslash Character (\)
- Add a backslash (\) before each special character to instruct QuickTest to treat the character literally.
- If the backslash (\) is used in conjunction with some characters that would otherwise be treated as literal characters, such as the letters n, t, w, or d, the combination indicates a special character. (转义符)
If a backslash character is used before a character that has no special meaning, the backslash is ignored. For example, \z matches z.
- Matching Any Single Character (except for \n) (.)
To match any single character including \n, enter: (.|\n)
- Matching Any Single Character in a List ([xy])
- Matching Any Single Character Not in a List ([^xy])
- Matching Any Single Character within a Range ([x-y])
Within brackets, the characters “.”, “*”, “[” and “\” are literal. For example, [.*] matches . or *. If the right bracket is the first character in the range, it is also literal.
- Matching Zero or More Specific Characters (*)
An asterisk (*) instructs QuickTest to match zero or more occurrences of the preceding character. For example: ca*r matches car, caaaaar, and cr.
- Matching One or More Specific Characters (+)
A plus sign (+) instructs QuickTest to match one or more occurrences of the preceding character. For example: ca+r matches car and caaaar, but not cr.
- Matching Zero or One Specific Character (?)
A question mark (?) instructs QuickTest to match zero or one occurrences of the preceding character. For example: ca?r matches car and cr, but nothing else.
- Grouping regular Expressions (())
- Matching One of Several Regular Expressions (|)
- Matching the Beginning of a Line (^)
- Matching the End of a Line ($)
- Matching Any AlphaNumeric Character Including the Underscore (\w)
- Matching Any Non-AlphaNumeric Character (\W)
- Combining Regular Expression Operations
Example:
To match any number between 0 and 1200, you need to match numbers with 1 digit, 2 digits, 3 digits, or 4 digits between 1000-1200.
The regular expression below matches any number between 0 and 1200.
([0-9]?[0-9]?[0-9]|1[01][0-9][0-9]|1200)