887 |
The compiled form of a regular expression can be saved and re-used at a |
The compiled form of a regular expression can be saved and re-used at a |
888 |
later time, possibly by a different program, and even on a host other |
later time, possibly by a different program, and even on a host other |
889 |
than the one on which it was compiled. Details are given in the |
than the one on which it was compiled. Details are given in the |
890 |
pcreprecompile documentation. |
pcreprecompile documentation. However, compiling a regular expression |
891 |
|
with one version of PCRE for use with a different version is not guar- |
892 |
|
anteed to work and may cause crashes. |
893 |
|
|
894 |
|
|
895 |
CHECKING BUILD-TIME OPTIONS |
CHECKING BUILD-TIME OPTIONS |
2388 |
|
|
2389 |
REVISION |
REVISION |
2390 |
|
|
2391 |
Last updated: 16 April 2007 |
Last updated: 24 April 2007 |
2392 |
Copyright (c) 1997-2007 University of Cambridge. |
Copyright (c) 1997-2007 University of Cambridge. |
2393 |
------------------------------------------------------------------------------ |
------------------------------------------------------------------------------ |
2394 |
|
|
2416 |
default value is zero. For example, this pattern has two callout |
default value is zero. For example, this pattern has two callout |
2417 |
points: |
points: |
2418 |
|
|
2419 |
(?C1)eabc(?C2)def |
(?C1)abc(?C2)def |
2420 |
|
|
2421 |
If the PCRE_AUTO_CALLOUT option bit is set when pcre_compile() is |
If the PCRE_AUTO_CALLOUT option bit is set when pcre_compile() is |
2422 |
called, PCRE automatically inserts callouts, all with number 255, |
called, PCRE automatically inserts callouts, all with number 255, |
4480 |
using pcre_dfa_exec() matching (by means of the \D escape sequence), |
using pcre_dfa_exec() matching (by means of the \D escape sequence), |
4481 |
produces the following output: |
produces the following output: |
4482 |
|
|
4483 |
re> /^?(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)$/ |
re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/ |
4484 |
data> 25jun04\P\D |
data> 25jun04\P\D |
4485 |
0: 25jun04 |
0: 25jun04 |
4486 |
data> 23dec3\P\D |
data> 23dec3\P\D |
4507 |
using the \R escape sequence to set the PCRE_DFA_RESTART option (\P and |
using the \R escape sequence to set the PCRE_DFA_RESTART option (\P and |
4508 |
\D are as above): |
\D are as above): |
4509 |
|
|
4510 |
re> /^?(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)$/ |
re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/ |
4511 |
data> 23ja\P\D |
data> 23ja\P\D |
4512 |
Partial match: 23ja |
Partial match: 23ja |
4513 |
data> n05\R\D |
data> n05\R\D |
4616 |
ent host and run them there. This works even if the new host has the |
ent host and run them there. This works even if the new host has the |
4617 |
opposite endianness to the one on which the patterns were compiled. |
opposite endianness to the one on which the patterns were compiled. |
4618 |
There may be a small performance penalty, but it should be insignifi- |
There may be a small performance penalty, but it should be insignifi- |
4619 |
cant. |
cant. However, compiling regular expressions with one version of PCRE |
4620 |
|
for use with a different version is not guaranteed to work and may |
4621 |
|
cause crashes. |
4622 |
|
|
4623 |
|
|
4624 |
SAVING A COMPILED PATTERN |
SAVING A COMPILED PATTERN |
4725 |
|
|
4726 |
REVISION |
REVISION |
4727 |
|
|
4728 |
Last updated: 06 March 2007 |
Last updated: 24 April 2007 |
4729 |
Copyright (c) 1997-2007 University of Cambridge. |
Copyright (c) 1997-2007 University of Cambridge. |
4730 |
------------------------------------------------------------------------------ |
------------------------------------------------------------------------------ |
4731 |
|
|
5193 |
return false (because the empty string is not a valid number): |
return false (because the empty string is not a valid number): |
5194 |
|
|
5195 |
int number; |
int number; |
5196 |
pcrecpp::RE::FullMatch("abc", "[a-z]+(\d+)?", &number); |
pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number); |
5197 |
|
|
5198 |
The matching interface supports at most 16 arguments per call. If you |
The matching interface supports at most 16 arguments per call. If you |
5199 |
need more, consider using the more general interface |
need more, consider using the more general interface |