\". For example, "^" match
beginning of string, but "\^" match character "^", "\\"
match "\" and so on. [],
which will match any one character from the list. If the first character after the
"[" is "^", the class matches any character not in the list. Within
a list, the "-" character is used to specify a range, so that a-z
represents all characters between "a" and "z", inclusive. If you want
"-" itself to be a member of a class, put it at the start or end of the list,
or escape it with a backslash. [-az], [az-],
and [a\-z]. All are different from [a-z], which specifies a class containing
twenty-six characters. If you want `]' you may place it at the start of
list or escape it with a backslash. Examples of queer ;) ranges: [\n- \x0D]
match any of #10,#11,#12,#13. [\-t] match any
digit, `-' or `t'. []-a] match any char from ']'..'a'.\n" matches a newline, "\t" a tab, "\r" a carriage return,
"\f" a form feed, etc. More generally, \xnn, where nn is a string
of hexadecimal digits, matches the character whose ASCII value is nn. ." metacharacter matches any character except "\n"
(unless you use /s modifier - see below. Note: in TRegExpr /s is
set by default). |" to separate
them, so that fee|fie|foe will match any of "fee", "fie", or "foe" in the
target string (as would f(e|i|o)e). The first alternative includes everything
from the last pattern delimiter ("(", "[", or the beginning of the
pattern) up to the first "|", and the last alternative contains everything
from the last "|" to the next pattern delimiter. For this reason, it's
common practice to include alternatives in parentheses, to minimize confusion
about where they start and end. foo|foot
against "barefoot", only the "foo" part will match, as that is the first alternative
tried, and it successfully matches the target string. (This might not seem important,
but it is important when you are capturing matched text using parentheses.) |" is interpreted as a literal within square brackets,
so if you write [fee|fie|foe] you're really only matching [feio|]. $0' or `$&').{.$DEFINE ComplexBraces}
in regexpr.pas, but note - it's not properly tested) of the form {n,m},
where n gives the minimum number of times to match the item and m gives the maximum.
The form {n} is equivalent to {n,n} and matches exactly n times.
The form {n,} matches n or more times. (If a curly bracket occurs in any
other context, it is treated as a regular character.) The * modifier is
equivalent to {0,}, the + modifier to {1,} and the ?
modifier to {0,1}. There is no limit to the size of n or m, but large
numbers will chew up more memory and slow down r.e. execution.
Character Meaning
^start of line $end of line .any character \quote next character *match zero or more +match one or more {n}Match exactly n times {n,\}Match at least n times {n,m}Match at least n but not more than m times [aeiou0-9]match a, e, i, o, u, and 0 through 9 ; [^aeiou0-9]match anything but a, e, i, o, u, and 0 thru 9 \wmatches an alphanumeric character (including " _")\Wa nonalphanumeric \dmatches a numeric character \Da non-numeric \smatches any space (same as [ \t\n\r\f])\Sa non space
Table 3: Metacharacters for Regular Expressions