summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-08-02 20:52:00 (GMT)
committerFred Drake <fdrake@acm.org>2001-08-02 20:52:00 (GMT)
commit51629c245a2d5895be040a27627b072a4f5479bf (patch)
tree11e5ccb8b5c6772fe9e4417ce5ccf9f14f4515d4 /Doc
parentc916cdc5ca98c21b0cde428941d0d7a164cf12d6 (diff)
downloadcpython-51629c245a2d5895be040a27627b072a4f5479bf.zip
cpython-51629c245a2d5895be040a27627b072a4f5479bf.tar.gz
cpython-51629c245a2d5895be040a27627b072a4f5479bf.tar.bz2
Add a caveat about boundary conditions and RE concatenation, so that the
documents do not make an overly-strong assertion about the properties of RE concatenation. Add an example of RE{m,} syntax and what it will and will not match.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libre.tex21
1 files changed, 12 insertions, 9 deletions
diff --git a/Doc/lib/libre.tex b/Doc/lib/libre.tex
index 45b1ca5..aa18814 100644
--- a/Doc/lib/libre.tex
+++ b/Doc/lib/libre.tex
@@ -61,13 +61,14 @@ matches a particular string, which comes down to the same thing).
Regular expressions can be concatenated to form new regular
expressions; if \emph{A} and \emph{B} are both regular expressions,
-then \emph{AB} is also an regular expression. If a string \emph{p}
+then \emph{AB} is also a regular expression. If a string \emph{p}
matches A and another string \emph{q} matches B, the string \emph{pq}
-will match AB. Thus, complex expressions can easily be constructed
-from simpler primitive expressions like the ones described here. For
-details of the theory and implementation of regular expressions,
-consult the Friedl book referenced below, or almost any textbook about
-compiler construction.
+will match AB if \emph{A} and \emph{B} do no specify boundary
+conditions that are no longer satisfied by \emph{pq}. Thus, complex
+expressions can easily be constructed from simpler primitive
+expressions like the ones described here. For details of the theory
+and implementation of regular expressions, consult the Friedl book
+referenced below, or almost any textbook about compiler construction.
A brief explanation of the format of regular expressions follows. For
further information and a gentler presentation, consult the Regular
@@ -138,9 +139,11 @@ not five.
\var{m} to \var{n} repetitions of the preceding RE, attempting to
match as many repetitions as possible. For example, \regexp{a\{3,5\}}
will match from 3 to 5 \character{a} characters. Omitting \var{n}
-specifies an infinite upper bound; you can't omit \var{m}. The comma
-may not be omitted or the modifier would be confused with the
-previously described form.
+specifies an infinite upper bound; you can't omit \var{m}. As an
+example, \regexp{a\{4,\}b} will match \code{aaaab}, a thousand
+\character{a} characters followed by a \code{b}, but not \code{aaab}.
+The comma may not be omitted or the modifier would be confused with
+the previously described form.
\item[\code{\{\var{m},\var{n}\}?}] Causes the resulting RE to
match from \var{m} to \var{n} repetitions of the preceding RE,