<?xml version="1.0" encoding="ascii"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>sre</title> <link rel="stylesheet" href="epydoc.css" type="text/css" /> <script type="text/javascript" src="epydoc.js"></script> </head> <body bgcolor="white" text="black" link="blue" vlink="#204080" alink="#204080"> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="epytext_example-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="http://epydoc.sourceforge.net">epydoc examples</a></th> </tr></table></th> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="100%"> <span class="breadcrumbs"> Module sre </span> </td> <td> <table cellpadding="0" cellspacing="0"> <!-- hide/show private --> <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" onclick="toggle_private();">hide private</a>]</span></td></tr> <tr><td align="right"><span class="options" >[<a href="frames.html" target="_top">frames</a >] | <a href="sre-module.html" target="_top">no frames</a>]</span></td></tr> </table> </td> </tr> </table> <!-- ==================== MODULE DESCRIPTION ==================== --> <h1 class="epydoc">Module sre</h1><p class="nomargin-top"><span class="codelink"><a href="sre-pysrc.html">source code</a></span></p> <pre class="literalblock"> Support for regular expressions (RE). This module provides regular expression matching operations similar to those found in Perl. It supports both 8-bit and Unicode strings; both the pattern and the strings being processed can contain null bytes and characters outside the US ASCII range. Regular expressions can contain both special and ordinary characters. Most ordinary characters, like "A", "a", or "0", are the simplest regular expressions; they simply match themselves. You can concatenate ordinary characters, so last matches the string 'last'. The special characters are: "." Matches any character except a newline. "^" Matches the start of the string. "$" Matches the end of the string. "*" Matches 0 or more (greedy) repetitions of the preceding RE. Greedy means that it will match as many repetitions as possible. "+" Matches 1 or more (greedy) repetitions of the preceding RE. "?" Matches 0 or 1 (greedy) of the preceding RE. *?,+?,?? Non-greedy versions of the previous three special characters. {m,n} Matches from m to n repetitions of the preceding RE. {m,n}? Non-greedy version of the above. "\\" Either escapes special characters or signals a special sequence. [] Indicates a set of characters. A "^" as the first character indicates a complementing set. "|" A|B, creates an RE that will match either A or B. (...) Matches the RE inside the parentheses. The contents can be retrieved or matched later in the string. (?iLmsux) Set the I, L, M, S, U, or X flag for the RE (see below). (?:...) Non-grouping version of regular parentheses. (?P<name>...) The substring matched by the group is accessible by name. (?P=name) Matches the text matched earlier by the group named name. (?#...) A comment; ignored. (?=...) Matches if ... matches next, but doesn't consume the string. (?!...) Matches if ... doesn't match next. The special sequences consist of "\\" and a character from the list below. If the ordinary character is not on the list, then the resulting RE will match the second character. \number Matches the contents of the group of the same number. \A Matches only at the start of the string. \Z Matches only at the end of the string. \b Matches the empty string, but only at the start or end of a word. \B Matches the empty string, but not at the start or end of a word. \d Matches any decimal digit; equivalent to the set [0-9]. \D Matches any non-digit character; equivalent to the set [^0-9]. \s Matches any whitespace character; equivalent to [ \t\n\r\f\v]. \S Matches any non-whitespace character; equiv. to [^ \t\n\r\f\v]. \w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]. With LOCALE, it will match the set [0-9_] plus characters defined as letters for the current locale. \W Matches the complement of \w. \\ Matches a literal backslash. This module exports the following functions: match Match a regular expression pattern to the beginning of a string. search Search a string for the presence of a pattern. sub Substitute occurrences of a pattern found in a string. subn Same as sub, but also return the number of substitutions made. split Split a string by the occurrences of a pattern. findall Find all occurrences of a pattern in a string. compile Compile a pattern into a RegexObject. purge Clear the regular expression cache. escape Backslash all non-alphanumerics in a string. Some of the functions in this module takes flags as optional parameters: I IGNORECASE Perform case-insensitive matching. L LOCALE Make \w, \W, \b, \B, dependent on the current locale. M MULTILINE "^" matches the beginning of lines as well as the string. "$" matches the end of lines as well as the string. S DOTALL "." matches any character at all, including the newline. X VERBOSE Ignore whitespace and comments for nicer looking RE's. U UNICODE Make \w, \W, \b, \B, dependent on the Unicode locale. This module also defines an exception 'error'. </pre> <hr /> <div class="fields"> <p><strong>Version:</strong> 2.2.1 </p> </div><!-- ==================== CLASSES ==================== --> <a name="section-Classes"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Classes</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-Classes" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a href="sre_constants.error-class.html" class="summary-name">error</a> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a href="sre.Scanner-class.html" class="summary-name" onclick="show_private();">Scanner</a> </td> </tr> </table> <!-- ==================== FUNCTIONS ==================== --> <a name="section-Functions"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Functions</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-Functions" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="match"></a><span class="summary-sig-name">match</span>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">string</span>, <span class="summary-sig-arg">flags</span>=<span class="summary-sig-default">0</span>)</span><br /> Try to apply the pattern at the start of the string, returning a match object, or None if no match was found.</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#match">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="search"></a><span class="summary-sig-name">search</span>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">string</span>, <span class="summary-sig-arg">flags</span>=<span class="summary-sig-default">0</span>)</span><br /> Scan through string looking for a match to the pattern, returning a match object, or None if no match was found.</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#search">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="sre-module.html#sub" class="summary-sig-name">sub</a>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">repl</span>, <span class="summary-sig-arg">string</span>, <span class="summary-sig-arg">count</span>=<span class="summary-sig-default">0</span>)</span><br /> Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl.</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#sub">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="sre-module.html#subn" class="summary-sig-name">subn</a>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">repl</span>, <span class="summary-sig-arg">string</span>, <span class="summary-sig-arg">count</span>=<span class="summary-sig-default">0</span>)</span><br /> Return a 2-tuple containing (new_string, number).</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#subn">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="split"></a><span class="summary-sig-name">split</span>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">string</span>, <span class="summary-sig-arg">maxsplit</span>=<span class="summary-sig-default">0</span>)</span><br /> Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings.</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#split">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="sre-module.html#findall" class="summary-sig-name">findall</a>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">string</span>, <span class="summary-sig-arg">flags</span>=<span class="summary-sig-default">0</span>)</span><br /> Return a list of all non-overlapping matches in the string.</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#findall">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="sre-module.html#finditer" class="summary-sig-name">finditer</a>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">string</span>, <span class="summary-sig-arg">flags</span>=<span class="summary-sig-default">0</span>)</span><br /> Return an iterator over all non-overlapping matches in the string.</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#finditer">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="compile"></a><span class="summary-sig-name">compile</span>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">flags</span>=<span class="summary-sig-default">0</span>)</span><br /> Compile a regular expression pattern, returning a pattern object.</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#compile">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="purge"></a><span class="summary-sig-name">purge</span>()</span><br /> Clear the regular expression cache</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#purge">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="template"></a><span class="summary-sig-name">template</span>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">flags</span>=<span class="summary-sig-default">0</span>)</span><br /> Compile a template pattern, returning a pattern object</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#template">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="escape"></a><span class="summary-sig-name">escape</span>(<span class="summary-sig-arg">pattern</span>)</span><br /> Escape all non-alphanumeric characters in pattern.</td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#escape">source code</a></span> </td> </tr> </table> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="_compile"></a><span class="summary-sig-name">_compile</span>(<span class="summary-sig-arg">*key</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#_compile">source code</a></span> </td> </tr> </table> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="_compile_repl"></a><span class="summary-sig-name">_compile_repl</span>(<span class="summary-sig-arg">*key</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#_compile_repl">source code</a></span> </td> </tr> </table> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="_expand"></a><span class="summary-sig-name">_expand</span>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">match</span>, <span class="summary-sig-arg">template</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#_expand">source code</a></span> </td> </tr> </table> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="_subx"></a><span class="summary-sig-name">_subx</span>(<span class="summary-sig-arg">pattern</span>, <span class="summary-sig-arg">template</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#_subx">source code</a></span> </td> </tr> </table> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="_pickle"></a><span class="summary-sig-name">_pickle</span>(<span class="summary-sig-arg">p</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="sre-pysrc.html#_pickle">source code</a></span> </td> </tr> </table> </td> </tr> </table> <!-- ==================== VARIABLES ==================== --> <a name="section-Variables"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Variables</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-Variables" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="IGNORECASE"></a><span class="summary-name">IGNORECASE</span> = <code title="2">2</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="I"></a><span class="summary-name">I</span> = <code title="2">2</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="LOCALE"></a><span class="summary-name">LOCALE</span> = <code title="4">4</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="L"></a><span class="summary-name">L</span> = <code title="4">4</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="UNICODE"></a><span class="summary-name">UNICODE</span> = <code title="32">32</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="U"></a><span class="summary-name">U</span> = <code title="32">32</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="MULTILINE"></a><span class="summary-name">MULTILINE</span> = <code title="8">8</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="M"></a><span class="summary-name">M</span> = <code title="8">8</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="DOTALL"></a><span class="summary-name">DOTALL</span> = <code title="16">16</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="S"></a><span class="summary-name">S</span> = <code title="16">16</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="VERBOSE"></a><span class="summary-name">VERBOSE</span> = <code title="64">64</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="X"></a><span class="summary-name">X</span> = <code title="64">64</code> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="TEMPLATE"></a><span class="summary-name">TEMPLATE</span> = <code title="1">1</code> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="T"></a><span class="summary-name">T</span> = <code title="1">1</code> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="DEBUG"></a><span class="summary-name">DEBUG</span> = <code title="128">128</code> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a href="sre-module.html#_cache" class="summary-name" onclick="show_private();">_cache</a> = <code title="{(<type 'str'>, '#.*', 0): re.compile(r'#.*'), (<type 'str'>, '( +|\\n)', 0): re.compile(r'( +|\n)'), (<type 'str'>, '(^>>>.*)\\n?', 8): re.compile(r'(?m)(^>>>.*)\n?'), (<type 'str'>, '<a[^>]*\\shref', 0): re.compile(r'<a[^>]*\shref'), (<type 'str'>, '["\'](.+-div)[\'"]', 0): re.compile(r'["\'](.+-div)[\\ '"]'), (<type 'str'>, '[^a-zA-Z0-9]', 0): re.compile(r'[^a-zA-Z0-9]'), (<type 'str'>, '\\$([^\\$]+)\\$', 0): re.compile(r'\$([^\$]+)\$'), ..."><code class="variable-group">{</code><code class="variable-group">(</code><type 'str'><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">#.*</code><code class="variable-quote">'</code><code class="variable-op">, </code>0<code class="variable-group">)</code><code class="variable-op">: </code>re.compile(r'#.<code class="re-op">*</code>')<code class="variable-op">, </code><code class="variable-group">(</code><type<code class="variable-ellipsis">...</code></code> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a href="sre-module.html#_cache_repl" class="summary-name" onclick="show_private();">_cache_repl</a> = <code title="{('#\\1\\3\\2', re.compile(r'#(..)(..)(..)')): ([(1, 1), (2, 3), (3, 2)], ['#', None, None, None]), ('#\\2\\2\\2', re.compile(r'#(..)(..)(..)')): ([(1, 2), (2, 2), (3, 2\ ..."><code class="variable-group">{</code><code class="variable-group">(</code><code class="variable-quote">'</code><code class="variable-string">#\\1\\3\\2</code><code class="variable-quote">'</code><code class="variable-op">, </code>re.compile(r'#<code class="re-group">(</code>..<code class="re-group">)</code><code class="re-group">(</code>..<code class="re-group">)</code><code class="re-group">(</code>..<code class="re-group">)</code>')<code class="variable-group">)</code><code class="variable-op">: </code><code class="variable-group">(</code><code class="variable-ellipsis">...</code></code> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="_MAXCACHE"></a><span class="summary-name">_MAXCACHE</span> = <code title="100">100</code> </td> </tr> </table> <!-- ==================== FUNCTION DETAILS ==================== --> <a name="section-FunctionDetails"></a> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Function Details</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-FunctionDetails" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> </table> <a name="sub"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">sub</span>(<span class="sig-arg">pattern</span>, <span class="sig-arg">repl</span>, <span class="sig-arg">string</span>, <span class="sig-arg">count</span>=<span class="sig-default">0</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="sre-pysrc.html#sub">source code</a></span> </td> </tr></table> <pre class="literalblock"> Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl. repl can be either a string or a callable; if a callable, it's passed the match object and must return a replacement string to be used. </pre> <dl class="fields"> </dl> </td></tr></table> </div> <a name="subn"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">subn</span>(<span class="sig-arg">pattern</span>, <span class="sig-arg">repl</span>, <span class="sig-arg">string</span>, <span class="sig-arg">count</span>=<span class="sig-default">0</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="sre-pysrc.html#subn">source code</a></span> </td> </tr></table> <pre class="literalblock"> Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made. repl can be either a string or a callable; if a callable, it's passed the match object and must return a replacement string to be used. </pre> <dl class="fields"> </dl> </td></tr></table> </div> <a name="findall"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">findall</span>(<span class="sig-arg">pattern</span>, <span class="sig-arg">string</span>, <span class="sig-arg">flags</span>=<span class="sig-default">0</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="sre-pysrc.html#findall">source code</a></span> </td> </tr></table> <pre class="literalblock"> Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result. </pre> <dl class="fields"> </dl> </td></tr></table> </div> <a name="finditer"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">finditer</span>(<span class="sig-arg">pattern</span>, <span class="sig-arg">string</span>, <span class="sig-arg">flags</span>=<span class="sig-default">0</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="sre-pysrc.html#finditer">source code</a></span> </td> </tr></table> <pre class="literalblock"> Return an iterator over all non-overlapping matches in the string. For each match, the iterator returns a match object. Empty matches are included in the result. </pre> <dl class="fields"> </dl> </td></tr></table> </div> <br /> <!-- ==================== VARIABLES DETAILS ==================== --> <a name="section-VariablesDetails"></a> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Variables Details</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-VariablesDetails" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> </table> <a name="_cache"></a> <div class="private"> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <h3 class="epydoc">_cache</h3> <dl class="fields"> </dl> <dl class="fields"> <dt>Value:</dt> <dd><table><tr><td><pre class="variable"> <code class="variable-group">{</code><code class="variable-group">(</code><type 'str'><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">#.*</code><code class="variable-quote">'</code><code class="variable-op">, </code>0<code class="variable-group">)</code><code class="variable-op">: </code>re.compile(r'#.<code class="re-op">*</code>')<code class="variable-op">,</code> <code class="variable-group">(</code><type 'str'><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">( +|\\n)</code><code class="variable-quote">'</code><code class="variable-op">, </code>0<code class="variable-group">)</code><code class="variable-op">: </code>re.compile(r'<code class="re-group">(</code> <code class="re-op">+</code><code class="re-op">|</code>\n<code class="re-group">)</code>')<code class="variable-op">,</code> <code class="variable-group">(</code><type 'str'><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">(^>>>.*)\\n?</code><code class="variable-quote">'</code><code class="variable-op">, </code>8<code class="variable-group">)</code><code class="variable-op">: </code>re.compile(r'<code class="re-flags">(?m)</code><code class="re-group">(</code>^>>>.<code class="re-op">*</code><code class="re-group">)</code>\n<code class="re-op">?</code>')<code class="variable-op">,</code> <code class="variable-group">(</code><type 'str'><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string"><a[^>]*\\shref</code><code class="variable-quote">'</code><code class="variable-op">, </code>0<code class="variable-group">)</code><code class="variable-op">: </code>re.compile(r'<a<code class="re-group">[^</code>><code class="re-group">]</code><code class="re-op">*</code>\shref')<code class="variable-op">,</code> <code class="variable-group">(</code><type 'str'><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">["\'](.+-div)[\'"]</code><code class="variable-quote">'</code><code class="variable-op">, </code>0<code class="variable-group">)</code><code class="variable-op">: </code>re.compile(r'<code class="re-group">[</code>"\'<code class="re-group">]</code><code class="re-group">(</code>.<code class="re-op">+</code>-div<code class="re-group">)</code><code class="re-group">[</code>\<span class="variable-linewrap"><img src="crarr.png" alt="\" /></span> '"<code class="re-group">]</code>')<code class="variable-op">,</code> <code class="variable-group">(</code><type 'str'><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">[^a-zA-Z0-9]</code><code class="variable-quote">'</code><code class="variable-op">, </code>0<code class="variable-group">)</code><code class="variable-op">: </code>re.compile(r'<code class="re-group">[</code><code class="re-op">^</code>a<code class="re-op">-</code>zA<code class="re-op">-</code>Z0<code class="re-op">-</code>9<code class="re-group">]</code>')<code class="variable-op">,</code> <code class="variable-group">(</code><type 'str'><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">\\$([^\\$]+)\\$</code><code class="variable-quote">'</code><code class="variable-op">, </code>0<code class="variable-group">)</code><code class="variable-op">: </code>re.compile(r'\$<code class="re-group">(</code><code class="re-group">[^</code>\$<code class="re-group">]</code><code class="re-op">+</code><code class="re-group">)</code>\$')<code class="variable-op">,</code> <code class="variable-ellipsis">...</code> </pre></td></tr></table> </dd> </dl> </td></tr></table> </div> <a name="_cache_repl"></a> <div class="private"> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <h3 class="epydoc">_cache_repl</h3> <dl class="fields"> </dl> <dl class="fields"> <dt>Value:</dt> <dd><table><tr><td><pre class="variable"> <code class="variable-group">{</code><code class="variable-group">(</code><code class="variable-quote">'</code><code class="variable-string">#\\1\\3\\2</code><code class="variable-quote">'</code><code class="variable-op">, </code>re.compile(r'#<code class="re-group">(</code>..<code class="re-group">)</code><code class="re-group">(</code>..<code class="re-group">)</code><code class="re-group">(</code>..<code class="re-group">)</code>')<code class="variable-group">)</code><code class="variable-op">: </code><code class="variable-group">(</code><code class="variable-group">[</code><code class="variable-group">(</code>1<code class="variable-op">, </code>1<code class="variable-group">)</code><code class="variable-op">,</code> <code class="variable-group">(</code>2<code class="variable-op">, </code>3<code class="variable-group">)</code><code class="variable-op">,</code> <code class="variable-group">(</code>3<code class="variable-op">, </code>2<code class="variable-group">)</code><code class="variable-group">]</code><code class="variable-op">,</code> <code class="variable-group">[</code><code class="variable-quote">'</code><code class="variable-string">#</code><code class="variable-quote">'</code><code class="variable-op">,</code> None<code class="variable-op">,</code> None<code class="variable-op">,</code> None<code class="variable-group">]</code><code class="variable-group">)</code><code class="variable-op">,</code> <code class="variable-group">(</code><code class="variable-quote">'</code><code class="variable-string">#\\2\\2\\2</code><code class="variable-quote">'</code><code class="variable-op">, </code>re.compile(r'#<code class="re-group">(</code>..<code class="re-group">)</code><code class="re-group">(</code>..<code class="re-group">)</code><code class="re-group">(</code>..<code class="re-group">)</code>')<code class="variable-group">)</code><code class="variable-op">: </code><code class="variable-group">(</code><code class="variable-group">[</code><code class="variable-group">(</code>1<code class="variable-op">, </code>2<code class="variable-group">)</code><code class="variable-op">, </code><code class="variable-group">(</code>2<code class="variable-op">, </code>2<code class="variable-group">)</code><code class="variable-op">, </code><code class="variable-group">(</code>3<code class="variable-op">, </code>2<code class="variable-group"></code><span class="variable-linewrap"><img src="crarr.png" alt="\" /></span> <code class="variable-ellipsis">...</code> </pre></td></tr></table> </dd> </dl> </td></tr></table> </div> <br /> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th> <a href="epytext_example-module.html">Home</a> </th> <!-- Tree link --> <th> <a href="module-tree.html">Trees</a> </th> <!-- Index link --> <th> <a href="identifier-index.html">Indices</a> </th> <!-- Help link --> <th> <a href="help.html">Help</a> </th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="http://epydoc.sourceforge.net">epydoc examples</a></th> </tr></table></th> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="100%%"> <tr> <td align="left" class="footer"> Generated by Epydoc 3.0.1 on Wed Jan 30 14:10:06 2008 </td> <td align="right" class="footer"> <a target="mainFrame" href="http://epydoc.sourceforge.net" >http://epydoc.sourceforge.net</a> </td> </tr> </table> <script type="text/javascript"> <!-- // Private objects are initially displayed (because if // javascript is turned off then we want them to be // visible); but by default, we want to hide them. So hide // them unless we have a cookie that says to show them. checkCookie(); // --> </script> </body> </html>