Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 57

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="21. Appendix" />
  <meta name="dc.subject" content="21. Appendix" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="appendixa.html" title="Chapter Contents" />
  <link rel="prev" href="systemtables.html" title="Virtuoso System Tables" />
  <link rel="next" href="apndxclientcompilance.html" title="Server &amp; client versions compatibility" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>21. Appendix</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="apndxregexp" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>21. Appendix</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="appendixa.html">Chapter Contents</a> | <a class="link" href="systemtables.html" title="Virtuoso System Tables">Prev</a> | <a class="link" href="apndxclientcompilance.html" title="Server &amp; client versions compatibility">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="appendixa.html">Appendix</a>
   </div>
    <br />
   <div>
      <a href="yacc.html">YACC SQL Grammar Reference</a>
   </div>
   <div>
      <a href="errors.html">Error Codes Reference</a>
   </div>
   <div>
      <a href="signalsandexitcodes.html">Signals and Exit codes</a>
   </div>
   <div>
      <a href="apparelnotes.html">Release Notes</a>
   </div>
   <div>
      <a href="support.html">Product Support</a>
   </div>
   <div>
      <a href="systemtables.html">Virtuoso System Tables</a>
   </div>
   <div class="selected">
      <a href="apndxregexp.html">Basic Syntax of Regular Expressions</a>
   </div>
   <div>
      <a href="apndxclientcompilance.html">Server &amp; client versions compatibility</a>
   </div>
    <br />
  </div>
  <div id="text">
    <a name="apndxregexp" />
    <h2>21.7. Basic Syntax of Regular Expressions</h2>

<p>The two special symbols: <span class="computeroutput">&#39;^&#39;</span> and 
<span class="computeroutput">&#39;$&#39;</span> indicate the <strong>start</strong> 
and the <strong>end</strong> of a string respectively, like so:</p>

<ul>
      <li>
        <span class="computeroutput">^The</span>: matches any string 
  that starts with The;</li>
      <li>
        <span class="computeroutput">of despair$</span>: matches a 
  string that ends in the substring of despair;</li>
      <li>
        <span class="computeroutput">^abc$</span>: a string that 
  starts and ends with abc -- that could only be abc itself!</li>
      <li>
        <span class="computeroutput">notice</span>: a string that 
  has the text notice in it.</li>
    </ul>

<p>Without either of the above special character you are allowing the pattern 
to occur anywhere inside the string.</p>

<p>The symbols <span class="computeroutput">&#39;*&#39;</span>, <span class="computeroutput">&#39;+&#39;</span>, 
and <span class="computeroutput">&#39;?&#39;</span> denote the number of times a character 
or a sequence of characters may occur.  What they mean is: zero or more, one or 
more, and zero or one.  Here are some examples:</p>

<ul>
      <li>
        <span class="computeroutput">ab*</span>: matches a string 
  that has an <strong>a</strong> followed by zero or more 
  <strong>b</strong>&#39;s (a, ab, abbb, etc.);</li>
      <li>
        <span class="computeroutput">ab+</span>: same, but there is 
  at least one <strong>b</strong> (ab, abbb, etc.);</li>
      <li>
        <span class="computeroutput">ab?</span>: there might be a 
  <strong>b</strong> or not;</li>
      <li>
        <span class="computeroutput">a?b+$</span>: a possible <strong>a</strong> 
  followed by one or more <strong>b</strong>&#39;s ending a string.</li>
    </ul>

<p>You can also use <strong>bounds</strong>, which come inside braces 
and indicate ranges in the number of occurrences: </p>

<ul>
      <li>
        <span class="computeroutput">ab{2}</span>: matches a string that has an 
  <strong>a</strong> followed by exactly two <strong>b</strong>&#39;s 
  (abb);</li>
      <li>
        <span class="computeroutput">ab{2,}</span>: there are at least two 
  <strong>b</strong>&#39;s (abb, abbbb, etc.);</li>
      <li>
        <span class="computeroutput">ab{3,5}</span>: from three to five 
  <strong>b</strong>&#39;s (abbb, abbbb, or abbbbb).</li>
    </ul>

<p>Note, that you must always specify the first number of a range 
(i.e, <span class="computeroutput">{0,2}</span>, not <span class="computeroutput">{,2}</span>).  
Also, as you may have noticed, the symbols &#39;*&#39;, &#39;+&#39;, and &#39;?&#39; have the same effect 
as using the bounds <span class="computeroutput">{0,}</span>, 
<span class="computeroutput">{1,}</span>, and <span class="computeroutput">{0,1}</span>, 
respectively.</p>

<p>Now, to quantify a sequence of characters, put them inside parentheses:</p>

<ul>
      <li>
        <span class="computeroutput">a(bc)*</span>: matches a string that has 
  an <strong>a</strong> followed by zero or more copies of the sequence bc;</li>
      <li>
        <span class="computeroutput">a(bc){1,5}</span>: one through five copies of bc.</li>
    </ul>

<p>There&#39;s also the &#39;|&#39; symbol, which works as an OR operator:</p>

<ul>
      <li>
        <span class="computeroutput">hi|hello</span>: matches a string that has 
  either hi or hello in it;</li>
      <li>
        <span class="computeroutput">(b|cd)ef</span>: a string that has either 
  bef or cdef;</li>
      <li>
        <span class="computeroutput">(a|b)*c</span>: a string that has a 
  sequence of alternating <strong>a</strong>&#39;s and <strong>b</strong>&#39;s 
  ending in a <strong>c</strong>;</li>
    </ul>

<p>A period (&#39;.&#39;) stands for any single character:</p>

<ul>
      <li>
        <span class="computeroutput">a.[0-9]</span>: matches a string that has 
  an <strong>a</strong> followed by one character and a digit;</li>
      <li>
        <span class="computeroutput">^.{3}$</span>: a string with exactly 3 characters.</li>
    </ul>

<p>
      <strong>Bracket expressions</strong> specify which characters are 
allowed in a single position of a string: </p>

<ul>
      <li>
        <span class="computeroutput">[ab]</span>: matches a string that has 
  either an <strong>a</strong> or a <strong>b</strong>
    (that&#39;s the same as <span class="computeroutput">a|b</span>);</li>
      <li>
        <span class="computeroutput">[a-d]</span>: a string that has lowercase 
  letters &#39;a&#39; through &#39;d&#39; (that&#39;s equal to <span class="computeroutput">a|b|c|d</span> 
  and even <span class="computeroutput">[abcd]</span>);</li>
      <li>
        <span class="computeroutput">^[a-zA-Z]</span>: a string that starts with a letter;</li>
      <li>
        <span class="computeroutput">[0-9]%</span>: a string that has a single 
  digit before a percent sign;</li>
      <li>
        <span class="computeroutput">,[a-zA-Z0-9]$</span>: a string that ends in 
  a comma followed by an alphanumeric character.</li>
    </ul>

<p>You can also list the characters that do NOT want -- just use a &#39;^&#39; as 
the first symbol in a bracketed expression (i.e., 
<span class="computeroutput">%[^a-zA-Z]%</span> matches a string with a character 
that is not a letter between two percent signs).</p>

<p>Do not forget that bracket expressions are an exception to that 
rule--inside them, all special characters, including the backslash (&#39;\&#39;), 
lose their special powers (i.e., <span class="computeroutput">[*\+?{}.]</span> 
matches exactly any of the characters inside the brackets).  
To include a literal &#39;]&#39; in the list, make it the first character 
(following a possible &#39;^&#39;). To include a literal &#39;-&#39;, make it the first or last 
character, or the second endpoint of a range.</p>

<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="systemtables.html" title="Virtuoso System Tables">Previous</a>
          <br />Virtuoso System Tables</td>
     <td align="center" width="34%">
          <a href="appendixa.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="apndxclientcompilance.html" title="Server &amp; client versions compatibility">Next</a>
          <br />Server &amp; client versions compatibility</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>