[Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.69,1.70
Tim Peters
tim_one@users.sourceforge.net
Sat, 03 Nov 2001 11:35:44 -0800
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv27485/python/Doc/lib
Modified Files:
libre.tex
Log Message:
Improved error msg when a symbolic group name is redefined. Added docs
and NEWS. Bugfix candidate? That's a dilemma for Anthony <wink>: /F
did fix a longstanding bug here, but the fix can cause code to raise an
exception that previously worked by accident.
Index: libre.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -d -r1.69 -r1.70
*** libre.tex 2001/10/20 04:24:09 1.69
--- libre.tex 2001/11/03 19:35:42 1.70
***************
*** 25,29 ****
\code{'\e\e\e\e'} as the pattern string, because the regular expression
must be \samp{\e\e}, and each backslash must be expressed as
! \samp{\e\e} inside a regular Python string literal.
The solution is to use Python's raw string notation for regular
--- 25,29 ----
\code{'\e\e\e\e'} as the pattern string, because the regular expression
must be \samp{\e\e}, and each backslash must be expressed as
! \samp{\e\e} inside a regular Python string literal.
The solution is to use Python's raw string notation for regular
***************
*** 179,184 ****
(defined below) are also acceptable inside a range. If you want to
include a \character{]} or a \character{-} inside a set, precede it with a
! backslash, or place it as the first character. The
! pattern \regexp{[]]} will match \code{']'}, for example.
You can match the characters not within a range by \dfn{complementing}
--- 179,184 ----
(defined below) are also acceptable inside a range. If you want to
include a \character{]} or a \character{-} inside a set, precede it with a
! backslash, or place it as the first character. The
! pattern \regexp{[]]} will match \code{']'}, for example.
You can match the characters not within a range by \dfn{complementing}
***************
*** 210,214 ****
\item[\code{(?...)}] This is an extension notation (a \character{?}
following a \character{(} is not meaningful otherwise). The first
! character after the \character{?}
determines what the meaning and further syntax of the construct is.
Extensions usually do not create a new group;
--- 210,214 ----
\item[\code{(?...)}] This is an extension notation (a \character{?}
following a \character{(} is not meaningful otherwise). The first
! character after the \character{?}
determines what the meaning and further syntax of the construct is.
Extensions usually do not create a new group;
***************
*** 232,242 ****
\item[\code{(?:...)}] A non-grouping version of regular parentheses.
Matches whatever regular expression is inside the parentheses, but the
! substring matched by the
group \emph{cannot} be retrieved after performing a match or
! referenced later in the pattern.
\item[\code{(?P<\var{name}>...)}] Similar to regular parentheses, but
the substring matched by the group is accessible via the symbolic group
! name \var{name}. Group names must be valid Python identifiers. A
symbolic group is also a numbered group, just as if the group were not
named. So the group named 'id' in the example above can also be
--- 232,243 ----
\item[\code{(?:...)}] A non-grouping version of regular parentheses.
Matches whatever regular expression is inside the parentheses, but the
! substring matched by the
group \emph{cannot} be retrieved after performing a match or
! referenced later in the pattern.
\item[\code{(?P<\var{name}>...)}] Similar to regular parentheses, but
the substring matched by the group is accessible via the symbolic group
! name \var{name}. Group names must be valid Python identifiers, and
! each group name must be defined only once within a regular expression. A
symbolic group is also a numbered group, just as if the group were not
named. So the group named 'id' in the example above can also be
***************
*** 293,297 ****
same number. Groups are numbered starting from 1. For example,
\regexp{(.+) \e 1} matches \code{'the the'} or \code{'55 55'}, but not
! \code{'the end'} (note
the space after the group). This special sequence can only be used to
match one of the first 99 groups. If the first digit of \var{number}
--- 294,298 ----
same number. Groups are numbered starting from 1. For example,
\regexp{(.+) \e 1} matches \code{'the the'} or \code{'55 55'}, but not
! \code{'the end'} (note
the space after the group). This special sequence can only be used to
match one of the first 99 groups. If the first digit of \var{number}
***************
*** 301,305 ****
be referenced with \regexp{\e 0}; instead, use \regexp{\e g<0>}.)
Inside the \character{[} and \character{]} of a character class, all numeric
! escapes are treated as characters.
\item[\code{\e A}] Matches only at the start of the string.
--- 302,306 ----
be referenced with \regexp{\e 0}; instead, use \regexp{\e g<0>}.)
Inside the \character{[} and \character{]} of a character class, all numeric
! escapes are treated as characters.
\item[\code{\e A}] Matches only at the start of the string.
***************
*** 388,392 ****
Compile a regular expression pattern into a regular expression
object, which can be used for matching using its \function{match()} and
! \function{search()} methods, described below.
The expression's behaviour can be modified by specifying a
--- 389,393 ----
Compile a regular expression pattern into a regular expression
object, which can be used for matching using its \function{match()} and
! \function{search()} methods, described below.
The expression's behaviour can be modified by specifying a
***************
*** 425,429 ****
\dataline{LOCALE}
Make \regexp{\e w}, \regexp{\e W}, \regexp{\e b}, and
! \regexp{\e B} dependent on the current locale.
\end{datadesc}
--- 426,430 ----
\dataline{LOCALE}
Make \regexp{\e w}, \regexp{\e W}, \regexp{\e b}, and
! \regexp{\e B} dependent on the current locale.
\end{datadesc}
***************
*** 457,461 ****
\dataline{VERBOSE}
This flag allows you to write regular expressions that look nicer.
! Whitespace within the pattern is ignored,
except when in a character class or preceded by an unescaped
backslash, and, when a line contains a \character{\#} neither in a
--- 458,462 ----
\dataline{VERBOSE}
This flag allows you to write regular expressions that look nicer.
! Whitespace within the pattern is ignored,
except when in a character class or preceded by an unescaped
backslash, and, when a line contains a \character{\#} neither in a
***************
*** 606,610 ****
position in the string matches the pattern; note that this is
different from finding a zero-length match at some point in the string.
!
The optional \var{pos} and \var{endpos} parameters have the same
meaning as for the \method{match()} method.
--- 607,611 ----
position in the string matches the pattern; note that this is
different from finding a zero-length match at some point in the string.
!
The optional \var{pos} and \var{endpos} parameters have the same
meaning as for the \method{match()} method.
***************
*** 660,664 ****
\begin{memberdesc}[RegexObject]{groupindex}
! A dictionary mapping any symbolic group names defined by
\regexp{(?P<\var{id}>)} to group numbers. The dictionary is empty if no
symbolic groups were used in the pattern.
--- 661,665 ----
\begin{memberdesc}[RegexObject]{groupindex}
! A dictionary mapping any symbolic group names defined by
\regexp{(?P<\var{id}>)} to group numbers. The dictionary is empty if no
symbolic groups were used in the pattern.
***************
*** 696,700 ****
in the pattern, an \exception{IndexError} exception is raised.
If a group is contained in a part of the pattern that did not match,
! the corresponding result is \code{None}. If a group is contained in a
part of the pattern that matched multiple times, the last match is
returned.
--- 697,701 ----
in the pattern, an \exception{IndexError} exception is raised.
If a group is contained in a part of the pattern that did not match,
! the corresponding result is \code{None}. If a group is contained in a
part of the pattern that matched multiple times, the last match is
returned.
***************
*** 702,706 ****
If the regular expression uses the \regexp{(?P<\var{name}>...)} syntax,
the \var{groupN} arguments may also be strings identifying groups by
! their group name. If a string argument is not used as a group name in
the pattern, an \exception{IndexError} exception is raised.
--- 703,707 ----
If the regular expression uses the \regexp{(?P<\var{name}>...)} syntax,
the \var{groupN} arguments may also be strings identifying groups by
! their group name. If a string argument is not used as a group name in
the pattern, an \exception{IndexError} exception is raised.
***************
*** 766,770 ****
The value of \var{pos} which was passed to the
\function{search()} or \function{match()} function. This is the index
! into the string at which the RE engine started looking for a match.
\end{memberdesc}
--- 767,771 ----
The value of \var{pos} which was passed to the
\function{search()} or \function{match()} function. This is the index
! into the string at which the RE engine started looking for a match.
\end{memberdesc}