From 7a307787b13ee438b49e5de30308608c8fb3a2e4 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 10 Sep 2017 09:29:52 +0000 Subject: [PATCH] More on pattern matching in parle git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@343039 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/parle/pattern.matching.xml | 164 ++++++++++++++++++++++++++- 1 file changed, 162 insertions(+), 2 deletions(-) diff --git a/reference/parle/pattern.matching.xml b/reference/parle/pattern.matching.xml index b153461029..f7629d2e5a 100644 --- a/reference/parle/pattern.matching.xml +++ b/reference/parle/pattern.matching.xml @@ -5,7 +5,7 @@ Parle pattern matching Pattern matching Parle supports a simplified regex matching. The supported syntax is the subset of the features defined by PCRE. -
+
Character representations @@ -24,7 +24,7 @@ \bBackspace. - \eESC, \x1b. + \eESC character, \x1b. \nNewline. @@ -55,6 +55,166 @@
+
+ Character Classes + + + Character classes + + + + SequenceDescription + + + + + [...]A single character listed or contained within a listed range. Ranges can be combined with the {+} and {-} operators. For example [a-z]{+}[0-9] is the same as [0-9a-z] and [a-z]{-}[aeiou] is the same as [b-df-hj-np-tv-z]. + + + [^...]A single character not listed and not contained within a listed range. + + + .Any character, [^\n] + + + \dDigit character, [0-9]. + + + \DNon-digit character, [^0-9]. + + + \sWhite space character, [ \t\n\r\f\v]. + + + \SNon-white space character, [^ \t\n\r\f\v]. + + + \wWord caracter, [a-zA-Z0-9_]. + + + \WNon-word caracter, [^a-zA-Z0-9_]. + + + +
+
+
+
+ Alternation and repetition + + + Alternation and repetition + + + + SequenceGreedyDescription + + + + + ...|...-Try subpatterns in alternation. + + + *yesMatch 0 or more times. + + + +yesMatch 1 or more times. + + + ?yesMatch 0 or 1 times. + + + {n}noMatch exactly n times. + + + {n,}yesMatch at least n times. + + + {n,m}yesMatch at least n times but no more than m times. + + + *?noMatch 0 or more times. + + + +?noMatch 1 or more times. + + + ??noMatch 0 or 1 times. + + + {n,}?noMatch at least n times. + + + {n,m}?noMatch at least n times but no more than m times. + + + {MACRO}-Include the regex MACRO in the current regex. + + + +
+
+
+
+ Anchors + + + Anchors + + + + SequenceDescription + + + + + ^Start of string or after a newline. + + + $End of string or before a newline. + + + +
+
+
+
+ Grouping + + + Grouping + + + + SequenceDescription + + + + + (...)Group a regular expression to override default operator precedence. + + + (?r-s:pattern) + + Apply option r and omit option s while interpreting pattern. Options may be zero or more of the characters i, s, or x. + + i means case-insensitive. -i means case-sensitive. + + s alters the meaning of '.' to match any character whatsoever. -s alters the meaning of '.' to match any character except '\n' + + x ignores comments and whitespace in patterns. Whitespace is ignored unless it is backslash-escaped, contained within ""s, or appears inside a character range. + + These options can be applied globally at the rules level by passing a combination of the bit flags to the lexer. + + + + (?# comment )Omit everything within (). The first ) character encountered ends the pattern. It is not possible for the comment to contain a ) character. The comment may span lines. + + + +
+
+