Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / re-objects.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="match-objects.html" />
<link rel="prev" href="node115.html" />
<link rel="parent" href="module-re.html" />
<link rel="next" href="match-objects.html" />
<meta name='aesop' content='information' />
<title>4.2.4 Regular Expression Objects </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="4.2.3 Module Contents"
href="node115.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="4.2 re "
href="module-re.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="4.2.5 Match Objects"
href="match-objects.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node115.html">4.2.3 Module Contents</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-re.html">4.2 re </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="match-objects.html">4.2.5 Match Objects</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION006240000000000000000"></A><A NAME="re-objects"></A>
<BR>
4.2.4 Regular Expression Objects
</H2>
<P>
Compiled regular expression objects support the following methods and
attributes:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-891' xml:id='l2h-891' class="method">match</tt></b>(</nobr></td>
<td><var>string</var><big>[</big><var>, pos</var><big>[</big><var>,
endpos</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
If zero or more characters at the beginning of <var>string</var> match
this regular expression, return a corresponding
<tt class="class">MatchObject</tt> instance. Return <code>None</code> if the string does not
match the pattern; note that this is different from a zero-length
match.
<P>
<span class="note"><b class="label">Note:</b>
If you want to locate a match anywhere in
<var>string</var>, use <tt class="method">search()</tt> instead.</span>
<P>
The optional second parameter <var>pos</var> gives an index in the string
where the search is to start; it defaults to <code>0</code>. This is not
completely equivalent to slicing the string; the
<code>'^'</code> pattern
character matches at the real beginning of the string and at positions
just after a newline, but not necessarily at the index where the search
is to start.
<P>
The optional parameter <var>endpos</var> limits how far the string will
be searched; it will be as if the string is <var>endpos</var> characters
long, so only the characters from <var>pos</var> to <code><var>endpos</var> -
1</code> will be searched for a match. If <var>endpos</var> is less than
<var>pos</var>, no match will be found, otherwise, if <var>rx</var> is a
compiled regular expression object,
<code><var>rx</var>.match(<var>string</var>, 0, 50)</code> is equivalent to
<code><var>rx</var>.match(<var>string</var>[:50], 0)</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-892' xml:id='l2h-892' class="method">search</tt></b>(</nobr></td>
<td><var>string</var><big>[</big><var>, pos</var><big>[</big><var>,
endpos</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Scan through <var>string</var> looking for a location where this regular
expression produces a match, and return a
corresponding <tt class="class">MatchObject</tt> instance. Return <code>None</code> if no
position in the string matches the pattern; note that this is
different from finding a zero-length match at some point in the string.
<P>
The optional <var>pos</var> and <var>endpos</var> parameters have the same
meaning as for the <tt class="method">match()</tt> method.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-893' xml:id='l2h-893' class="method">split</tt></b>(</nobr></td>
<td><var>string</var><big>[</big><var>,
maxsplit<code> = 0</code></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Identical to the <tt class="function">split()</tt> function, using the compiled pattern.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-894' xml:id='l2h-894' class="method">findall</tt></b>(</nobr></td>
<td><var>string</var><big>[</big><var>, pos</var><big>[</big><var>,
endpos</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Identical to the <tt class="function">findall()</tt> function, using the compiled pattern.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-895' xml:id='l2h-895' class="method">finditer</tt></b>(</nobr></td>
<td><var>string</var><big>[</big><var>, pos</var><big>[</big><var>,
endpos</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Identical to the <tt class="function">finditer()</tt> function, using the compiled pattern.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-896' xml:id='l2h-896' class="method">sub</tt></b>(</nobr></td>
<td><var>repl, string</var><big>[</big><var>, count<code> = 0</code></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Identical to the <tt class="function">sub()</tt> function, using the compiled pattern.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-897' xml:id='l2h-897' class="method">subn</tt></b>(</nobr></td>
<td><var>repl, string</var><big>[</big><var>,
count<code> = 0</code></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Identical to the <tt class="function">subn()</tt> function, using the compiled pattern.
</dl>
<P>
<dl><dt><b><tt id='l2h-898' xml:id='l2h-898' class="member">flags</tt></b></dt>
<dd>
The flags argument used when the RE object was compiled, or
<code>0</code> if no flags were provided.
</dl>
<P>
<dl><dt><b><tt id='l2h-899' xml:id='l2h-899' class="member">groupindex</tt></b></dt>
<dd>
A dictionary mapping any symbolic group names defined by
<tt class="regexp">(?P&lt;<var>id</var>&gt;)</tt> to group numbers. The dictionary is empty if no
symbolic groups were used in the pattern.
</dl>
<P>
<dl><dt><b><tt id='l2h-900' xml:id='l2h-900' class="member">pattern</tt></b></dt>
<dd>
The pattern string from which the RE object was compiled.
</dl>
<P>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="4.2.3 Module Contents"
href="node115.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="4.2 re "
href="module-re.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="4.2.5 Match Objects"
href="match-objects.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node115.html">4.2.3 Module Contents</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-re.html">4.2 re </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="match-objects.html">4.2.5 Match Objects</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>