'(?@())' matches balanced parenthesis,
'(?@[])' matches balanced square brackets,
'(?@{})' matches balanced curly brackets
Pattern | Class Name | Explanation |
---|---|---|
[a-c] | Range | This matches any character in the range 'a' to 'c' |
[a-cde] | Bracket | This matches any character in the range 'a' to 'e' |
[\-x] | Bracket | This matches the '-' character or the 'x' character |
[^ab] | Bracket | This matches any characters except 'a' or 'b' |
. | Any | This matches any character except \n. To match any character at all, you might try [\d\D]. |
{n1,n2} | Multi | This matches between n1 and n2 instances of the previous Pattern, where n1 and n2 are integers. |
{n1,} | Multi | This matches at least n1 instances of the previous Pattern |
* | Multi | The same as {0,} |
? | Multi | The same as {0,1} |
+ | Multi | The same as {1,} |
*? | MultiMin | By default, {n1,n2}, {n1,}, *, ?, +, match the largest number of occurences of the preceeding Pattern. If any of these is followed by a ? it will attempt, instead, to match the fewest occurents of the preceeding Pattern. |
(a|b) | OrMark | This matches the character a or b, and returns the matched character as a backreference. In other words, if you call Regex's search method with "a" you will find that an "a" is returned by stringMatched(1). |
(a) | OrMark | This matches the character "a" as a backreference. |
\b | Boundary | This matches a word boundary, either a beginning \w character, an ending \w character, or one of these two sequences: \w\W, \W\w. |
(?: ... ) | Or | like the parenthesis above, but does not create a backreference. |
(?= ... ) | lookAhead | A zero-length lookahead. Thus the pattern "foo(?=bar)" will match "foo", but only if followed by "bar". |
(?! ... ) | lookAhead | Another form of zero-length lookahead. However, it only matches if the thing in the ()'s is not matched. Thus "foo(?!bar)" matches "foo" only if it is not followed by "bar". |
(?# ... ) | A comment | |
\B | Boundary | A non-word Boundary. Essentially the same as (?!\b). |
\d | Range | Essentially the same as [0-9]. |
\D | Bracket | Not a digit. Essentially the same as [^0-9]. |
\w | Bracket | A word character, essentially the same as [a-zA-Z_0-9] |
\W | Bracket | Not a word character. |
\s | Bracket | A white-space character, [ \t\b\n\r]. |
\S | Bracket | A non white-space character. |
\1 | BackMatch | Match the contents of the first backreference. Thus "([a-d]).*\1" matches the first 5 characters of "axyzabc". |
(?i) | Tell this pattern to ignore case during a match. | |
$ | End | Matches the end of a String (the \n character is considered the end of the string by this pattern element). |
\Z | End | Matches the end of a String. The \n character does not count as the end. |
^ | Start | Matches the beginning of a String. This is either the absolute beginning, or right after a \n character. |
\A | Start | Matches the absolute beginning of a String. |
\G | BackG | Matches the place we left off in our last search of this String with this pattern or, failing that, the beginning of the String. |