Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 4995

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>regex</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_replace.html">next</a> | <a href="_match_lp__String_cm__String_rp.html">previous</a> | <a href="_replace.html">forward</a> | <a href="_match_lp__String_cm__String_rp.html">backward</a> | <a href="_regular_spexpressions.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<div><a href="index.html" title="">Macaulay2Doc</a> > <a href="___The_sp__Macaulay2_splanguage.html" title="">The Macaulay2 language</a> > <a href="_strings_spand_spnets.html" title="">strings and nets</a> > <a href="_regular_spexpressions.html" title="">regular expressions</a> > <a href="_regex.html" title="">regex</a></div>
<hr/>
<div><h1>regex</h1>
<div class="single"><h2>Synopsis</h2>
<ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>z = regex(p,n,r,s)</tt><br/><tt>z = regex(p,n,s)</tt></div>
</dd></dl>
</div>
</li>
<li><div class="single">Inputs:<ul><li><span><tt>p</tt>, a regular expression describing a pattern</span></li>
<li><span><tt>n</tt>, the starting position in <tt>s</tt> at which to begin the search.  If it is omitted, the search starts at the beginning of the string.</span></li>
<li><span><tt>r</tt>, the extent of the search.  If it is omitted, the search extends to the end of the string.  If it is 0, then the regular expression matches only at the starting position.  If it is negative, then positions to the left of the starting position are examined for matches.</span></li>
<li><span><tt>s</tt>, the subject string to be searched</span></li>
</ul>
</div>
</li>
<li><div class="single">Outputs:<ul><li><span><tt>z</tt>, a list of pairs of integers describing the first substring of <tt>s</tt> found that matches the pattern, or <a href="_null.html" title="the unique member of the empty class">null</a> if nothing matched.  The substring begins at a position between <tt>n</tt> and <tt>n+r</tt>.</span></li>
</ul>
</div>
</li>
</ul>
</div>
<div class="single"><h2>Description</h2>
<div>The value returned is a list of pairs of integers corresponding to the parenthesized subexpressions successfully matched, suitable for use as the first argument of <a href="_substring.html" title="extract part of a string">substring</a>.  The first member of each pair is the offset within <tt>s</tt> of the substring matched, and the second is the length.<table class="examples"><tr><td><pre>i1 : s = "The cat is black.";</pre>
</td></tr>
<tr><td><pre>i2 : word = ///\b([a-z]+)\b///;</pre>
</td></tr>
<tr><td><pre>i3 : m = regex(word|" "|word,s)

o3 = {(4, 6), (4, 3), (8, 2)}

o3 : List</pre>
</td></tr>
<tr><td><pre>i4 : substring(m#0,s)

o4 = cat is</pre>
</td></tr>
<tr><td><pre>i5 : substring(m#1,s)

o5 = cat</pre>
</td></tr>
<tr><td><pre>i6 : substring(m#2,s)

o6 = is</pre>
</td></tr>
<tr><td><pre>i7 : s = "aa     aaaa";</pre>
</td></tr>
<tr><td><pre>i8 : m = regex("a+",0,s)

o8 = {(0, 2)}

o8 : List</pre>
</td></tr>
<tr><td><pre>i9 : substring(m#0,s)

o9 = aa</pre>
</td></tr>
<tr><td><pre>i10 : m = regex("a+",2,s)

o10 = {(7, 4)}

o10 : List</pre>
</td></tr>
<tr><td><pre>i11 : substring(m#0,s)

o11 = aaaa</pre>
</td></tr>
<tr><td><pre>i12 : m = regex("a+",2,3,s)</pre>
</td></tr>
<tr><td><pre>i13 : s = "line 1\nline 2\nline 3";</pre>
</td></tr>
<tr><td><pre>i14 : m = regex("^.*$",8,-8,s)

o14 = {(7, 6)}

o14 : List</pre>
</td></tr>
<tr><td><pre>i15 : substring(m#0,s)

o15 = line 2</pre>
</td></tr>
<tr><td><pre>i16 : m = regex("^",10,-10,s)

o16 = {(7, 0)}

o16 : List</pre>
</td></tr>
<tr><td><pre>i17 : substring(0,m#0#0,s)

o17 = line 1</pre>
</td></tr>
<tr><td><pre>i18 : substring(m#0#0,s)

o18 = line 2
      line 3</pre>
</td></tr>
<tr><td><pre>i19 : m = regex("^.*$",4,-10,s)

o19 = {(0, 6)}

o19 : List</pre>
</td></tr>
<tr><td><pre>i20 : substring(m#0,s)

o20 = line 1</pre>
</td></tr>
<tr><td><pre>i21 : m = regex("a.*$",4,-10,s)</pre>
</td></tr>
</table>
</div>
</div>
<div class="single"><h2>See also</h2>
<ul><li><span><a href="_regular_spexpressions.html" title="">regular expressions</a></span></li>
<li><span><a href="_match_lp__String_cm__String_rp.html" title="regular expression matching">match</a> -- regular expression matching</span></li>
<li><span><a href="_replace.html" title="replacement in strings and lists">replace</a> -- replacement in strings and lists</span></li>
<li><span><a href="_substring.html" title="extract part of a string">substring(Sequence,String)</a> -- extract part of a string</span></li>
</ul>
</div>
<div class="waystouse"><h2>Ways to use <tt>regex</tt> :</h2>
<ul><li>regex(String,String)</li>
<li>regex(String,ZZ,String)</li>
<li>regex(String,ZZ,ZZ,String)</li>
</ul>
</div>
</div>
</body>
</html>