1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::RegularExpression</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.html" class="namespace">Poco</a></h1>
<h1 class="symbol">class RegularExpression</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Foundation<br />
<b>Package:</b> RegExp<br />
<b>Header:</b> Poco/RegularExpression.h</p>
<h2>Description</h2>
<div class="description">
<p>A class for working with regular expressions. Implemented using PCRE, the Perl Compatible Regular Expressions library by Philip Hazel (see <a href="http://www.pcre.org" target="_blank">http://www.pcre.org</a>). </p>
</div>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.RegularExpression.html#9727" title="Poco::RegularExpression::extract()">extract</a>, <a href="Poco.RegularExpression.html#9702" title="Poco::RegularExpression::match()">match</a>, <a href="Poco.RegularExpression.html#9725" title="Poco::RegularExpression::operator !=()">operator !=</a>, <a href="Poco.RegularExpression.html#9723" title="Poco::RegularExpression::operator ==()">operator ==</a>, <a href="Poco.RegularExpression.html#9736" title="Poco::RegularExpression::split()">split</a>, <a href="Poco.RegularExpression.html#9745" title="Poco::RegularExpression::subst()">subst</a>, <a href="Poco.RegularExpression.html#9758" title="Poco::RegularExpression::substOne()">substOne</a></p>
<h2>Nested Classes</h2>
<h3><a href="Poco.RegularExpression.Match.html" class="class">struct Match</a></h3>
<p> <a href="Poco.RegularExpression.Match.html"><img src="images/arrow.gif" alt="more..." style="vertical-align:baseline;" border="0" /> </a></p>
<h2>Types</h2>
<h3><a name="9696">MatchVec</a></h3>
<p class="decl">typedef std::vector < <a href="Poco.RegularExpression.Match.html" title="struct Poco::RegularExpression::Match">Match</a> > <a href="Poco.RegularExpression.html#9696" title="Poco::RegularExpression::MatchVec">MatchVec</a>;</p>
<div class="description">
<p></p>
</div>
<h2>Enumerations</h2>
<h3><a name="9669">Options</a></h3>
<div class="description">
<p>Some of the following options can only be passed to the constructor; some can be passed only to matching functions, and some can be used everywhere. </p>
<p></p>
<ul>
<li><a href="Poco.RegularExpression.html#9669" title="enum Poco::RegularExpression::Options">Options</a> marked [ctor] can be passed to the constructor. </li>
<li><a href="Poco.RegularExpression.html#9669" title="enum Poco::RegularExpression::Options">Options</a> marked [match] can be passed to match, extract, split and subst. </li>
<li><a href="Poco.RegularExpression.html#9669" title="enum Poco::RegularExpression::Options">Options</a> marked [subst] can be passed to subst. </li>
</ul>
<p>See the PCRE documentation for more information. </p>
</div>
<p class="decl"><a name="9670">RE_CASELESS</a> = 0x00000001</p>
<div class="description">
<p>case insensitive matching (/i) [ctor] </p>
</div>
<p class="decl"><a name="9671">RE_MULTILINE</a> = 0x00000002</p>
<div class="description">
<p>enable multi-line mode; affects ^ and $ (/m) [ctor] </p>
</div>
<p class="decl"><a name="9672">RE_DOTALL</a> = 0x00000004</p>
<div class="description">
<p>dot matches all characters, including newline (/s) [ctor] </p>
</div>
<p class="decl"><a name="9673">RE_EXTENDED</a> = 0x00000004</p>
<div class="description">
<p>totally ignore whitespace (/x) [ctor] </p>
</div>
<p class="decl"><a name="9674">RE_ANCHORED</a> = 0x00000010</p>
<div class="description">
<p>treat pattern as if it starts with a ^ [ctor, match] </p>
</div>
<p class="decl"><a name="9675">RE_DOLLAR_ENDONLY</a> = 0x00000020</p>
<div class="description">
<p>dollar matches end-of-string only, not last newline in string [ctor] </p>
</div>
<p class="decl"><a name="9676">RE_EXTRA</a> = 0x00000040</p>
<div class="description">
<p>enable optional PCRE functionality [ctor] </p>
</div>
<p class="decl"><a name="9677">RE_NOTBOL</a> = 0x00000080</p>
<div class="description">
<p>circumflex does not match beginning of string [match] </p>
</div>
<p class="decl"><a name="9678">RE_NOTEOL</a> = 0x00000100</p>
<div class="description">
<p>$ does not match end of string [match] </p>
</div>
<p class="decl"><a name="9679">RE_UNGREEDY</a> = 0x00000200</p>
<div class="description">
<p>make quantifiers ungreedy [ctor] </p>
</div>
<p class="decl"><a name="9680">RE_NOTEMPTY</a> = 0x00000400</p>
<div class="description">
<p>empty string never matches [match] </p>
</div>
<p class="decl"><a name="9681">RE_UTF8</a> = 0x00000800</p>
<div class="description">
<p>assume pattern and subject is UTF-8 encoded [ctor] </p>
</div>
<p class="decl"><a name="9682">RE_NO_AUTO_CAPTURE</a> = 0x00001000</p>
<div class="description">
<p>disable numbered capturing parentheses [ctor, match] </p>
</div>
<p class="decl"><a name="9683">RE_NO_UTF8_CHECK</a> = 0x00002000</p>
<div class="description">
<p>do not check validity of UTF-8 code sequences [match] </p>
</div>
<p class="decl"><a name="9684">RE_FIRSTLINE</a> = 0x00040000</p>
<div class="description">
<p>an unanchored pattern is required to match before or at the first newline in the subject string, though the matched text may continue over the newline [ctor] </p>
</div>
<p class="decl"><a name="9685">RE_DUPNAMES</a> = 0x00080000</p>
<div class="description">
<p>names used to identify capturing subpatterns need not be unique [ctor] </p>
</div>
<p class="decl"><a name="9686">RE_NEWLINE_CR</a> = 0x00100000</p>
<div class="description">
<p>assume newline is CR ('\r'), the default [ctor] </p>
</div>
<p class="decl"><a name="9687">RE_NEWLINE_LF</a> = 0x00200000</p>
<div class="description">
<p>assume newline is LF ('\n') [ctor] </p>
</div>
<p class="decl"><a name="9688">RE_NEWLINE_CRLF</a> = 0x00300000</p>
<div class="description">
<p>assume newline is CRLF ("\r\n") [ctor] </p>
</div>
<p class="decl"><a name="9689">RE_NEWLINE_ANY</a> = 0x00400000</p>
<div class="description">
<p>assume newline is any valid <a href="Poco.Unicode.html" title="class Poco::Unicode">Unicode</a> newline character [ctor] </p>
</div>
<p class="decl"><a name="9690">RE_NEWLINE_ANYCRLF</a> = 0x00500000</p>
<div class="description">
<p>assume newline is any of CR, LF, CRLF [ctor] </p>
</div>
<p class="decl"><a name="9691">RE_GLOBAL</a> = 0x10000000</p>
<div class="description">
<p>replace all occurences (/g) [subst] </p>
</div>
<p class="decl"><a name="9692">RE_NO_VARS</a> = 0x20000000</p>
<div class="description">
<p>treat dollar in replacement string as ordinary character [subst] </p>
</div>
<h2>Constructors</h2>
<h3><a name="9697">RegularExpression</a></h3>
<p class="decl"><a href="Poco.RegularExpression.html" title="class Poco::RegularExpression">RegularExpression</a>(<br /> const std::string & pattern,<br /> int options = 0,<br /> bool study = true<br />);</p>
<div class="description">
<p>Creates a regular expression and parses the given pattern. If study is true, the pattern is analyzed and optimized. This is mainly useful if the pattern is used more than once. For a description of the options, please see the PCRE documentation. Throws a <a href="Poco.RegularExpressionException.html" title="class Poco::RegularExpressionException">RegularExpressionException</a> if the patter cannot be compiled. </p>
</div>
<h2>Destructor</h2>
<h3><a name="9701">~RegularExpression</a></h3>
<p class="decl">~<a href="Poco.RegularExpression.html" title="class Poco::RegularExpression">RegularExpression</a>();</p>
<div class="description">
<p>Destroys the regular expression. </p>
</div>
<h2>Member Functions</h2>
<h3><a name="9727">extract</a></h3>
<p class="decl">int extract(<br /> const std::string & subject,<br /> std::string & str,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Matches the given subject string against the pattern. Returns the captured string. Throws a <a href="Poco.RegularExpressionException.html" title="class Poco::RegularExpressionException">RegularExpressionException</a> in case of an error. Returns the number of matches. </p>
</div>
<h3><a name="9731">extract</a></h3>
<p class="decl">int extract(<br /> const std::string & subject,<br /> std::string::size_type offset,<br /> std::string & str,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Matches the given subject string, starting at offset, against the pattern. Returns the captured string. Throws a <a href="Poco.RegularExpressionException.html" title="class Poco::RegularExpressionException">RegularExpressionException</a> in case of an error. Returns the number of matches. </p>
</div>
<h3><a name="9702">match</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">int match(<br /> const std::string & subject,<br /> <a href="Poco.RegularExpression.Match.html" title="struct Poco::RegularExpression::Match">Match</a> & mtch,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Matches the given subject string against the pattern. Returns the position of the first captured substring in mtch. If no part of the subject matches the pattern, mtch.offset is std::string::npos and mtch.length is 0. Throws a <a href="Poco.RegularExpressionException.html" title="class Poco::RegularExpressionException">RegularExpressionException</a> in case of an error. Returns the number of matches. </p>
</div>
<h3><a name="9706">match</a></h3>
<p class="decl">int match(<br /> const std::string & subject,<br /> std::string::size_type offset,<br /> <a href="Poco.RegularExpression.Match.html" title="struct Poco::RegularExpression::Match">Match</a> & mtch,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Matches the given subject string, starting at offset, against the pattern. Returns the position of the captured substring in mtch. If no part of the subject matches the pattern, mtch.offset is std::string::npos and mtch.length is 0. Throws a <a href="Poco.RegularExpressionException.html" title="class Poco::RegularExpressionException">RegularExpressionException</a> in case of an error. Returns the number of matches. </p>
</div>
<h3><a name="9711">match</a></h3>
<p class="decl">int match(<br /> const std::string & subject,<br /> std::string::size_type offset,<br /> <a href="Poco.RegularExpression.html#9696" title="Poco::RegularExpression::MatchVec">MatchVec</a> & matches,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Matches the given subject string against the pattern. The first entry in matches contains the position of the captured substring. The following entries identify matching subpatterns. See the PCRE documentation for a more detailed explanation. If no part of the subject matches the pattern, matches is empty. Throws a <a href="Poco.RegularExpressionException.html" title="class Poco::RegularExpressionException">RegularExpressionException</a> in case of an error. Returns the number of matches. </p>
</div>
<h3><a name="9716">match</a></h3>
<p class="decl">bool match(<br /> const std::string & subject,<br /> std::string::size_type offset = 0<br />) const;</p>
<div class="description">
<p>Returns true if and only if the subject matches the regular expression. </p>
<p>Internally, this method sets the <a href="Poco.RegularExpression.html#9674" title="Poco::RegularExpression::RE_ANCHORED">RE_ANCHORED</a> and <a href="Poco.RegularExpression.html#9680" title="Poco::RegularExpression::RE_NOTEMPTY">RE_NOTEMPTY</a> options for matching, which means that the empty string will never match and the pattern is treated as if it starts with a ^. </p>
</div>
<h3><a name="9719">match</a></h3>
<p class="decl">bool match(<br /> const std::string & subject,<br /> std::string::size_type offset,<br /> int options<br />) const;</p>
<div class="description">
<p>Returns true if and only if the subject matches the regular expression. </p>
</div>
<h3><a name="9754">match</a> <img src="images/static.gif" alt="static" title="static" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">static bool match(<br /> const std::string & subject,<br /> const std::string & pattern,<br /> int options = 0<br />);</p>
<div class="description">
<p>Matches the given subject string against the regular expression given in pattern, using the given options. </p>
</div>
<h3><a name="9725">operator !=</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool operator != (<br /> const std::string & subject<br />) const;</p>
<div class="description">
<p>Returns true if and only if the subject does not match the regular expression. </p>
<p>Internally, this method sets the <a href="Poco.RegularExpression.html#9674" title="Poco::RegularExpression::RE_ANCHORED">RE_ANCHORED</a> and <a href="Poco.RegularExpression.html#9680" title="Poco::RegularExpression::RE_NOTEMPTY">RE_NOTEMPTY</a> options for matching, which means that the empty string will never match and the pattern is treated as if it starts with a ^. </p>
</div>
<h3><a name="9723">operator ==</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool operator == (<br /> const std::string & subject<br />) const;</p>
<div class="description">
<p>Returns true if and only if the subject matches the regular expression. </p>
<p>Internally, this method sets the <a href="Poco.RegularExpression.html#9674" title="Poco::RegularExpression::RE_ANCHORED">RE_ANCHORED</a> and <a href="Poco.RegularExpression.html#9680" title="Poco::RegularExpression::RE_NOTEMPTY">RE_NOTEMPTY</a> options for matching, which means that the empty string will never match and the pattern is treated as if it starts with a ^. </p>
</div>
<h3><a name="9736">split</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">int split(<br /> const std::string & subject,<br /> std::vector < std::string > & strings,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Matches the given subject string against the pattern. The first entry in captured is the captured substring. The following entries contain substrings matching subpatterns. See the PCRE documentation for a more detailed explanation. If no part of the subject matches the pattern, captured is empty. Throws a <a href="Poco.RegularExpressionException.html" title="class Poco::RegularExpressionException">RegularExpressionException</a> in case of an error. Returns the number of matches. </p>
</div>
<h3><a name="9740">split</a></h3>
<p class="decl">int split(<br /> const std::string & subject,<br /> std::string::size_type offset,<br /> std::vector < std::string > & strings,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Matches the given subject string against the pattern. The first entry in captured is the captured substring. The following entries contain substrings matching subpatterns. See the PCRE documentation for a more detailed explanation. If no part of the subject matches the pattern, captured is empty. Throws a <a href="Poco.RegularExpressionException.html" title="class Poco::RegularExpressionException">RegularExpressionException</a> in case of an error. Returns the number of matches. </p>
</div>
<h3><a name="9745">subst</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">int subst(<br /> std::string & subject,<br /> const std::string & replacement,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Substitute in subject all matches of the pattern with replacement. If <a href="Poco.RegularExpression.html#9691" title="Poco::RegularExpression::RE_GLOBAL">RE_GLOBAL</a> is specified as option, all matches are replaced. Otherwise, only the first match is replaced. Occurences of $<n> (for example, $1, $2, ...) in replacement are replaced with the corresponding captured string. $0 is the original subject string. Returns the number of replaced occurences. </p>
</div>
<h3><a name="9749">subst</a></h3>
<p class="decl">int subst(<br /> std::string & subject,<br /> std::string::size_type offset,<br /> const std::string & replacement,<br /> int options = 0<br />) const;</p>
<div class="description">
<p>Substitute in subject all matches of the pattern with replacement, starting at offset. If <a href="Poco.RegularExpression.html#9691" title="Poco::RegularExpression::RE_GLOBAL">RE_GLOBAL</a> is specified as option, all matches are replaced. Otherwise, only the first match is replaced. Unless <a href="Poco.RegularExpression.html#9692" title="Poco::RegularExpression::RE_NO_VARS">RE_NO_VARS</a> is specified, occurences of $<n> (for example, $0, $1, $2, ... $9) in replacement are replaced with the corresponding captured string. $0 is the captured substring. $1 ... $n are the substrings maching the subpatterns. Returns the number of replaced occurences. </p>
</div>
<h3><a name="9758">substOne</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">std::string::size_type substOne(<br /> std::string & subject,<br /> std::string::size_type offset,<br /> const std::string & replacement,<br /> int options<br />) const;</p>
<div class="description">
<p></p>
</div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright © 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>
</div>
</body>
</html>
|