Prev | Current Page 419 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The group with id 0 corresponds to the whole
match while the groups starting from one are user defined using the standard parentheses. The pattern
((.)(\d{2})) defines three groups; the first matches one character followed by two digits, the second
is the first character of the previous group, and the third the two digits.
Table 8-10
Syntax Description
(?:pattern) Defines a non-capturing group. This kind of group cannot be retrieved using
back-references or matched groups and it is useful for grouping alternations.
\1 to \9 A back-reference is a numeric value prefixed with the backslash character.
A back-reference corresponds to a matched group. So the expression ([ab])x\1
matches axa and bxb but not axb or bxa.
| The pipe character is used to create an alternation. The symbol breaks a pattern
into two parts: the string on the left of it and the string on the right; if one of the
two is a valid pattern for the tested string, the pattern is a match. Alternations can
also be used inside groups. The expression j(ohn|ane) matches john and jane
but not jim.


Pages:
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431