Commit bed92ee2 authored by Raymond Hettinger's avatar Raymond Hettinger

SF patch #800899: Making "|" directive from REs a bit clearer.

parent 62685d36
...@@ -186,14 +186,13 @@ except \character{\textasciicircum}. ...@@ -186,14 +186,13 @@ except \character{\textasciicircum}.
\item[\character{|}]\code{A|B}, where A and B can be arbitrary REs, \item[\character{|}]\code{A|B}, where A and B can be arbitrary REs,
creates a regular expression that will match either A or B. An creates a regular expression that will match either A or B. An
arbitrary number of REs can be separated by the \character{|} in this arbitrary number of REs can be separated by the \character{|} in this
way. This can be used inside groups (see below) as well. REs way. This can be used inside groups (see below) as well. As the target
separated by \character{|} are tried from left to right, and the first string is scanned, REs separated by \character{|} are tried from left to
one that allows the complete pattern to match is considered the right. When one pattern completely matches, that branch is accepted.
accepted branch. This means that if \code{A} matches, \code{B} will This means that once \code{A} matches, \code{B} will not be tested further,
never be tested, even if it would produce a longer overall match. In even if it would produce a longer overall match. In other words, the
other words, the \character{|} operator is never greedy. To match a \character{|} operator is never greedy. To match a literal \character{|},
literal \character{|}, use \regexp{\e|}, or enclose it inside a use \regexp{\e|}, or enclose it inside a character class, as in \regexp{[|]}.
character class, as in \regexp{[|]}.
\item[\code{(...)}] Matches whatever regular expression is inside the \item[\code{(...)}] Matches whatever regular expression is inside the
parentheses, and indicates the start and end of a group; the contents parentheses, and indicates the start and end of a group; the contents
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment