Fred Drake avatar Fred Drake committed b59ad4b

Document the finditer() function and method.
This closes SF bug #520904.

Explain that many of the escapes supported by string literals are also
supported by the RE compiler, and list which ones.
This closes SF bug #529923.

Comments (0)

Files changed (1)

Doc/lib/libre.tex

 
 \item[\code{\e Z}]Matches only at the end of the string.
 
-\item[\code{\e \e}] Matches a literal backslash.
+\end{list}
 
-\end{list}
+Most of the standard escapes supported by Python string literals are
+also accepted by the regular expression parser:
+
+\begin{verbatim}
+\a      \b      \f      \n
+\r      \t      \v      \x
+\\
+\end{verbatim}
+
+Note that octal escapes are not included.  While the parser can
+attempt to determine whether a character is being specified by it's
+ordinal value expressed in octal, doing so yields an expression which
+is relatively difficult to maintain, as the same syntax is used to
+refer to numbered groups.
 
 
 \subsection{Matching vs. Searching \label{matching-searching}}
   \versionadded{1.5.2}
 \end{funcdesc}
 
+\begin{funcdesc}{finditer}{pattern, string}
+  Return an iterator over all non-overlapping matches for the RE
+  \var{pattern} in \var{string}.  For each match, the iterator returns
+  a match object.  Empty matches are included in the result.
+  \versionadded{2.2}
+\end{funcdesc}
+
 \begin{funcdesc}{sub}{pattern, repl, string\optional{, count}}
   Return the string obtained by replacing the leftmost non-overlapping
   occurrences of \var{pattern} in \var{string} by the replacement
 Identical to the \function{findall()} function, using the compiled pattern.
 \end{methoddesc}
 
+\begin{methoddesc}[RegexObject]{finditer}{string}
+Identical to the \function{finditer()} function, using the compiled pattern.
+\end{methoddesc}
+
 \begin{methoddesc}[RegexObject]{sub}{repl, string\optional{, count\code{ = 0}}}
 Identical to the \function{sub()} function, using the compiled pattern.
 \end{methoddesc}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.