Lines Matching refs:PCRE
5 // This is a variant of PCRE's pcrecpp.h, originally written at Google.
7 // compilation as PCRE in namespace re2.
9 // C++ interface to the pcre regular-expression library. PCRE supports
16 // This module uses the pcre library and hence supports its syntax
19 // http://www.google.com/search?q=pcre
39 // CHECK(PCRE::FullMatch("hello", "h.*o"));
42 // CHECK(!PCRE::FullMatch("hello", "e"));
57 // PCRE re(utf8_pattern, PCRE::UTF8);
58 // CHECK(PCRE::FullMatch(utf8_string, re));
68 // CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i));
71 // CHECK(!PCRE::FullMatch("ruby", "(.*)", &i));
74 // CHECK(!PCRE::FullMatch("ruby:1234", "\\w+:\\d+", &s));
77 // CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s));
80 // CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i));
83 // CHECK(!PCRE::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i));
92 // CHECK(PCRE::PartialMatch("hello", "ell"));
96 // CHECK(PCRE::PartialMatch("x*100 + 20", "(\\d+)", &number));
102 // PCRE makes it easy to use any string as a regular expression, without
105 // If speed is of the essence, you can create a pre-compiled "PCRE"
110 // PCRE pattern("h.*o");
112 // if (PCRE::FullMatch(str, pattern)) ...;
129 // while (PCRE::Consume(&input, "(\\w+) = (\\d+)\n", &var, &value)) {
143 // PCRE::FindAndConsume(&input, "(\\w+)", &word)
157 // CHECK(PCRE::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)",
165 #include <pcre.h>
172 struct pcre;
183 #define pcre_compile(a,b,c,d,e) ({ (void)(a); (void)(b); *(c)=""; *(d)=0; (void)(e); ((pcre*)0); })
194 // pre-compiled regular expression. An "PCRE" object is safe for
196 class PCRE {
206 // Options are same value as those in pcre. We provide them here
207 // to avoid users needing to include pcre.h and also to isolate
208 // users from pcre should we change the underlying library.
222 // pass in a string or a "const char*" wherever an "PCRE" is expected.
223 PCRE(const char* pattern);
224 PCRE(const char* pattern, Option option);
225 PCRE(const string& pattern);
226 PCRE(const string& pattern, Option option);
227 PCRE(const char *pattern, const PCRE_Options& re_option);
228 PCRE(const string& pattern, const PCRE_Options& re_option);
230 ~PCRE();
232 // The string specification for this PCRE. E.g.
233 // PCRE re("ab*c?d+");
237 // If PCRE could not be created properly, returns an error string.
241 // Whether the PCRE has hit a match limit during execution.
255 // You can pass in a "const char*" or a "string" or a "PCRE" for "pattern".
278 // PCRE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
280 bool operator ()(const StringPiece& text, const PCRE& re, // 3..16 args
304 bool operator ()(const StringPiece& text, const PCRE& re, // 3..16 args
329 bool operator ()(StringPiece* input, const PCRE& pattern, // 3..16 args
355 bool operator ()(StringPiece* input, const PCRE& pattern,
383 // CHECK(PCRE::Replace(&s, "b+", "d"));
390 const PCRE& pattern,
398 // CHECK(PCRE::GlobalReplace(&s, "b+", "d"));
404 const PCRE& pattern,
414 const PCRE& pattern,
419 // this PCRE. It checks that:
420 // * The PCRE has enough parenthesized subexpressions to satisfy all
430 // @return true, iff @p rewrite is suitable for use with the PCRE.
473 // I.e. for PCRE("(foo)|(bar)|(baz)") it will return 2, 3, and 4 when matching
475 // When matching PCRE("(foo)|hello") against "hello", it will return 1.
502 pcre* Compile(Anchor anchor);
506 pcre* re_full_; // For full matches
507 pcre* re_partial_; // For partial matches
513 DISALLOW_EVIL_CONSTRUCTORS(PCRE);
516 // PCRE_Options allow you to set the PCRE::Options, plus any pcre
519 // stack usage. Setting a limit to <= 0 lets PCRE pick a sensible default
521 // If PCRE hits a limit during a match, it may return a false negative,
531 PCRE_Options() : option_(PCRE::None), match_limit_(0), stack_limit_(0), report_errors_(true) {}
533 PCRE::Option option() const { return option_; }
534 void set_option(PCRE::Option option) {
553 PCRE::Option option_;
575 class PCRE::Arg {
577 // Empty constructor so we can declare arrays of PCRE::Arg
652 inline PCRE::Arg::Arg() : arg_(NULL), parser_(parse_null) { }
653 inline PCRE::Arg::Arg(void* p) : arg_(p), parser_(parse_null) { }
655 inline bool PCRE::Arg::Parse(const char* str, int n) const {
661 inline PCRE::Arg Hex(type* ptr) { \
662 return PCRE::Arg(ptr, PCRE::Arg::parse_ ## name ## _hex); } \
663 inline PCRE::Arg Octal(type* ptr) { \
664 return PCRE::Arg(ptr, PCRE::Arg::parse_ ## name ## _octal); } \
665 inline PCRE::Arg CRadix(type* ptr) { \
666 return PCRE::Arg(ptr, PCRE::Arg::parse_ ## name ## _cradix); }