...
Scroll Table Layout | ||
---|---|---|
|
Character/meta-character | Matches | Examples |
---|---|---|
anystring | an occurrence of the string “anystring” | “soft” matches parasoft, software, soften, etc. |
. | exactly one non-null character | “.at” matches hat, cat, bat, fat, etc., but not “at” |
? | 0 or 1 occurrences of the preceding character | “j?test” matches either jtest or test |
* | 0 or more occurrences of preceding character | “a*soft” matches asoft, or aaaaasoft; |
+ | 1 or more occurrences of the preceding character | “a+soft” matches aaaaasoft, or aaasoft, but not asoft |
[ ] | matches one occurrence of any character inside the brackets; ^ inverts the brackets metacharacter | “[cpy]up” matches cup, pup, or yup |
[A-Z] | any uppercase letters from A to Z | “[A-Z]” matches any uppercase letter from A to Z |
[a-z] | any lowercase letters from a -z | “[a-z]” matches any lowercase letter from a-z |
[0-9] | any integer from 0 to 9 | “rule[0-9]” matches any expression that begins with “rule” and ends with an integer |
(?i) | ignore case | “(?i)ParaSoft” matches ParaSoft, PARASOFT, parasoft or paraSOFT |
{} | like *, but the string it matches must be of the length specified in the braces | “a{2}” matches aa, aaa, aaaa, etc. |
| | matches the string before the “|”, the string after the “|”, or both | “rulewizard|codewizard” matches rulewizard, codewizard, or both |
Additional Information
- The caret symbol (^) indicates the beginning of a string in parentheses. The dollar sign ($) indicates the end of a string in parentheses. Thus, to get an exact match for a string, use the format
^(STRING)$
. For example^(soft)$
would only flag “soft”. - If you want a violation reported if the expression is detected, disable the Regexp window’s Negate option.
- If you want a violation reported when the expression is not detected, enable the Regexp window’s Negate option.
- Regular expressions searches are case sensitive by default.
- When using regular expressions, the backslash (\) is an escape character that you can use to match a "." , "*", or another character that has a non-literal meaning.