Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e1798ec8
Commit
e1798ec8
authored
Sep 10, 2003
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF patch #800899: Making "|" directive from REs a bit clearer.
parent
f7e2563c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
Doc/lib/libre.tex
Doc/lib/libre.tex
+7
-8
No files found.
Doc/lib/libre.tex
View file @
e1798ec8
...
...
@@ -186,14 +186,13 @@ except \character{\textasciicircum}.
\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
arbitrary number of REs can be separated by the
\character
{
|
}
in this
way. This can be used inside groups (see below) as well. REs
separated by
\character
{
|
}
are tried from left to right, and the first
one that allows the complete pattern to match is considered the
accepted branch. This means that if
\code
{
A
}
matches,
\code
{
B
}
will
never be tested, even if it would produce a longer overall match. In
other words, the
\character
{
|
}
operator is never greedy. To match a
literal
\character
{
|
}
, use
\regexp
{
\e
|
}
, or enclose it inside a
character class, as in
\regexp
{
[|]
}
.
way. This can be used inside groups (see below) as well. As the target
string is scanned, REs separated by
\character
{
|
}
are tried from left to
right. When one pattern completely matches, that branch is accepted.
This means that once
\code
{
A
}
matches,
\code
{
B
}
will not be tested further,
even if it would produce a longer overall match. In other words, the
\character
{
|
}
operator is never greedy. To match a literal
\character
{
|
}
,
use
\regexp
{
\e
|
}
, or enclose it inside a character class, as in
\regexp
{
[|]
}
.
\item
[\code{(...)}]
Matches whatever regular expression is inside the
parentheses, and indicates the start and end of a group; the contents
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment