| 195 |
RE_Options & set_caseless(bool) |
RE_Options & set_caseless(bool) |
| 196 |
.sp |
.sp |
| 197 |
which sets or unsets the modifier. Moreover, PCRE_EXTRA_MATCH_LIMIT can be |
which sets or unsets the modifier. Moreover, PCRE_EXTRA_MATCH_LIMIT can be |
| 198 |
accessed through the \fBset_match_limit()\fR and \fBmatch_limit()\fR member |
accessed through the \fBset_match_limit()\fP and \fBmatch_limit()\fP member |
| 199 |
functions. Setting \fImatch_limit\fR to a non-zero value will limit the |
functions. Setting \fImatch_limit\fP to a non-zero value will limit the |
| 200 |
execution of pcre to keep it from doing bad things like blowing the stack or |
execution of pcre to keep it from doing bad things like blowing the stack or |
| 201 |
taking an eternity to return a result. A value of 5000 is good enough to stop |
taking an eternity to return a result. A value of 5000 is good enough to stop |
| 202 |
stack blowup in a 2MB thread stack. Setting \fImatch_limit\fR to zero disables |
stack blowup in a 2MB thread stack. Setting \fImatch_limit\fP to zero disables |
| 203 |
match limiting. Alternatively, you can call \fBmatch_limit_recursion()\fP |
match limiting. Alternatively, you can call \fBmatch_limit_recursion()\fP |
| 204 |
which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much PCRE |
which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much PCRE |
| 205 |
recurses. \fBmatch_limit()\fP limits the number of matches PCRE does; |
recurses. \fBmatch_limit()\fP limits the number of matches PCRE does; |
| 207 |
therefore the amount of stack that is used. |
therefore the amount of stack that is used. |
| 208 |
.P |
.P |
| 209 |
Normally, to pass one or more modifiers to a RE class, you declare |
Normally, to pass one or more modifiers to a RE class, you declare |
| 210 |
a \fIRE_Options\fR object, set the appropriate options, and pass this |
a \fIRE_Options\fP object, set the appropriate options, and pass this |
| 211 |
object to a RE constructor. Example: |
object to a RE constructor. Example: |
| 212 |
.sp |
.sp |
| 213 |
RE_options opt; |
RE_options opt; |
| 216 |
.sp |
.sp |
| 217 |
RE_options has two constructors. The default constructor takes no arguments and |
RE_options has two constructors. The default constructor takes no arguments and |
| 218 |
creates a set of flags that are off by default. The optional parameter |
creates a set of flags that are off by default. The optional parameter |
| 219 |
\fIoption_flags\fR is to facilitate transfer of legacy code from C programs. |
\fIoption_flags\fP is to facilitate transfer of legacy code from C programs. |
| 220 |
This lets you do |
This lets you do |
| 221 |
.sp |
.sp |
| 222 |
RE(pattern, |
RE(pattern, |
| 230 |
.sp |
.sp |
| 231 |
If you are going to pass one of the most used modifiers, there are some |
If you are going to pass one of the most used modifiers, there are some |
| 232 |
convenience functions that return a RE_Options class with the |
convenience functions that return a RE_Options class with the |
| 233 |
appropriate modifier already set: \fBCASELESS()\fR, \fBUTF8()\fR, |
appropriate modifier already set: \fBCASELESS()\fP, \fBUTF8()\fP, |
| 234 |
\fBMULTILINE()\fR, \fBDOTALL\fR(), and \fBEXTENDED()\fR. |
\fBMULTILINE()\fP, \fBDOTALL\fP(), and \fBEXTENDED()\fP. |
| 235 |
.P |
.P |
| 236 |
If you need to set several options at once, and you don't want to go through |
If you need to set several options at once, and you don't want to go through |
| 237 |
the pains of declaring a RE_Options object and setting several options, there |
the pains of declaring a RE_Options object and setting several options, there |
| 238 |
is a parallel method that give you such ability on the fly. You can concatenate |
is a parallel method that give you such ability on the fly. You can concatenate |
| 239 |
several \fBset_xxxxx()\fR member functions, since each of them returns a |
several \fBset_xxxxx()\fP member functions, since each of them returns a |
| 240 |
reference to its class object. For example, to pass PCRE_CASELESS, |
reference to its class object. For example, to pass PCRE_CASELESS, |
| 241 |
PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one statement, you may write: |
PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one statement, you may write: |
| 242 |
.sp |
.sp |
| 260 |
Example: read lines of the form "var = value" from a string. |
Example: read lines of the form "var = value" from a string. |
| 261 |
string contents = ...; // Fill string somehow |
string contents = ...; // Fill string somehow |
| 262 |
pcrecpp::StringPiece input(contents); // Wrap in a StringPiece |
pcrecpp::StringPiece input(contents); // Wrap in a StringPiece |
| 263 |
|
.sp |
| 264 |
string var; |
string var; |
| 265 |
int value; |
int value; |
| 266 |
pcrecpp::RE re("(\e\ew+) = (\e\ed+)\en"); |
pcrecpp::RE re("(\e\ew+) = (\e\ed+)\en"); |