Home | History | Annotate | Download | only in pcrecpp

Lines Matching refs:RE

47 using pcrecpp::RE;
71 RE pattern("ruby:\\d+");
80 RE pattern("ruby:(\\d+)");
94 RE line_matcher(".*\n");
116 RE newre(buf);
133 CHECK(RE("([0-9a-fA-F]+)[uUlL]*").FullMatch(#value, Hex(&v))); \
135 CHECK(RE("([0-9a-fA-FxX]+)[uUlL]*").FullMatch("0x" #value, CRadix(&v))); \
159 CHECK(RE("([0-7]+)[uUlL]*").FullMatch(#value, Octal(&v))); \
161 CHECK(RE("([0-9a-fA-FxX]+)[uUlL]*").FullMatch("0" #value, CRadix(&v))); \
185 CHECK(RE("(-?[0-9]+)[uUlL]*").FullMatch(#value, &v)); \
187 CHECK(RE("(-?[0-9a-fA-FxX]+)[uUlL]*").FullMatch(#value, CRadix(&v))); \
336 RE re(t->regexp, RE_Options().set_newline_mode(PCRE2_NEWLINE_CRLF)
338 assert(re.error().empty());
340 CHECK(re.Replace(t->rewrite, &one));
343 const int replace_count = re.GlobalReplace(t->rewrite, &all);
348 // One final test: test \r\n replacement when we're not in CRLF mode
350 RE re("b*", RE_Options().set_newline_mode(PCRE2_NEWLINE_CR)
352 assert(re.error().empty());
354 CHECK_EQ(re.GlobalReplace("bb", &all), 9);
358 RE re("b*", RE_Options().set_newline_mode(PCRE2_NEWLINE_LF)
360 assert(re.error().empty());
362 CHECK_EQ(re.GlobalReplace("bb", &all), 9);
374 CHECK(RE("(.*)@([^.]*)").Extract("\\2!\\1", "boris@kremvax.ru", &s));
377 // check the RE interface as well
378 CHECK(RE(".*").Extract("'\\0'", "foo", &s));
380 CHECK(!RE("bar").Extract("'\\0'", "baz", &s));
392 RE r("\\s*(\\w+)"); // matches a word, possibly proceeded by whitespace
408 RE r("(\\w+)"); // matches a word
425 RE r("(foo)|(bar)|(baz)");
441 CHECK(RE("(foo)|hello").FullMatch("hello", &a));
458 RE re("(\\w+)*b", options_ml);
459 CHECK(re.PartialMatch(text_good) == true);
460 CHECK(re.PartialMatch(text_bad) == false);
461 CHECK(re.FullMatch(text_good) == false);
462 CHECK(re.FullMatch(text_bad) == false);
465 RE re2("(\\w+)*b", options_ml);
473 RE re3("(\\w+)*b", options_mlr);
480 RE re4("(\\w+)*b", options_mlr);
490 string quoted = RE::QuoteMeta(unquoted);
491 RE re(quoted, options);
492 CHECK(re.FullMatch(unquoted));
499 string quoted = RE::QuoteMeta(unquoted);
500 RE re(quoted, options);
501 CHECK(!re.FullMatch(should_not_match));
583 RE(regex,options).FullMatch(str, &captured);
585 RE(regex,options).PartialMatch(str, &captured);
605 CHECK(RE(regex,options).FullMatch(str));
607 CHECK(RE(regex,options).PartialMatch(str));
610 CHECK(!RE(regex,options).FullMatch(str));
612 CHECK(!RE(regex,options).PartialMatch(str));
705 RE re("(world|universe)$", options);
706 CHECK(re.Extract("\\1", str , &captured));
712 re.Extract("\\1",str, &captured );
779 RE orig("HELLO.*world", options);
782 RE copy1(orig);
785 RE copy2("not a match");
835 CHECK(RE("h.*o").FullMatch("hello"));
836 CHECK(!RE("h.*o").FullMatch("othello")); // Must be anchored at front
837 CHECK(!RE("h.*o").FullMatch("hello!")); // Must be anchored at end
838 CHECK(RE("a*").FullMatch("aaaa")); // Fullmatch with normal op
839 CHECK(RE("a*?").FullMatch("aaaa")); // Fullmatch with nongreedy op
840 CHECK(RE("a*?\\z").FullMatch("aaaa")); // Two unusual ops
845 CHECK(RE("\\d+").FullMatch("1001"));
848 CHECK(RE("(\\d+)").FullMatch("1001", &i));
850 CHECK(RE("(-?\\d+)").FullMatch("-123", &i));
852 CHECK(!RE("()\\d+").FullMatch("10", &i));
853 CHECK(!RE("(\\d+)").FullMatch("1234567890123456789012345678901234567890",
857 CHECK(RE("1(\\d*)4").FullMatch("1234", &i));
859 CHECK(RE("(\\d)\\d+").FullMatch("1234", &i));
861 CHECK(RE("(-\\d)\\d+").FullMatch("-1234", &i));
863 CHECK(RE("(\\d)").PartialMatch("1234", &i));
865 CHECK(RE("(-\\d)").PartialMatch("-1234", &i));
869 CHECK(RE("h(.*)o").FullMatch("hello", &s));
874 CHECK(RE("(\\w+):(\\d+)").FullMatch("ruby:1234", &sp, &i));
880 CHECK(RE("(\\w+):(\\d+)").FullMatch("ruby:1234", &s, &i));
885 CHECK(RE("he(.*)lo").FullMatch("hello", (char*)NULL));
886 CHECK(RE("h(.*)o").FullMatch("hello", (string*)NULL));
887 CHECK(RE("h(.*)o").FullMatch("hello", (StringPiece*)NULL));
888 CHECK(RE("(.*)").FullMatch("1234", (int*)NULL));
890 CHECK(RE("(.*)").FullMatch("1234567890123456", (long long*)NULL));
892 CHECK(RE("(.*)").FullMatch("123.4567890123456", (double*)NULL));
893 CHECK(RE("(.*)").FullMatch("123.4567890123456", (float*)NULL));
896 CHECK(!RE("h(.*)lo").FullMatch("hello", &s, (char*)NULL));
897 CHECK(!RE("(.*)").FullMatch("hello", (int*)NULL));
898 CHECK(!RE("(.*)").FullMatch("1234567890123456", (int*)NULL));
899 CHECK(!RE("(.*)").FullMatch("hello", (double*)NULL));
900 CHECK(!RE("(.*)").FullMatch("hello", (float*)NULL));
903 CHECK(RE("(\\w+)(:)(\\d+)").FullMatch("ruby:1234", &s, (void*)NULL, &i));
910 CHECK(RE("(H)ello").FullMatch("Hello", &c));
915 CHECK(RE("(H)ello").FullMatch("Hello", &c));
920 CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
921 CHECK(RE("(-?\\d+)").FullMatch("-100", &v)); CHECK_EQ(v, -100);
922 CHECK(RE("(-?\\d+)").FullMatch("32767", &v)); CHECK_EQ(v, 32767);
923 CHECK(RE("(-?\\d+)").FullMatch("-32768", &v)); CHECK_EQ(v, -32768);
924 CHECK(!RE("(-?\\d+)").FullMatch("-32769", &v));
925 CHECK(!RE("(-?\\d+)").FullMatch("32768", &v));
929 CHECK(RE("(\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
930 CHECK(RE("(\\d+)").FullMatch("32767", &v)); CHECK_EQ(v, 32767);
931 CHECK(RE("(\\d+)").FullMatch("65535", &v)); CHECK_EQ(v, 65535);
932 CHECK(!RE("(\\d+)").FullMatch("65536", &v));
938 CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
939 CHECK(RE("(-?\\d+)").FullMatch("-100", &v)); CHECK_EQ(v, -100);
940 CHECK(RE("(-?\\d+)").FullMatch("2147483647", &v)); CHECK_EQ(v, max_value);
941 CHECK(RE("(-?\\d+)").FullMatch("-2147483648", &v)); CHECK_EQ(v, min_value);
942 CHECK(!RE("(-?\\d+)").FullMatch("-2147483649", &v));
943 CHECK(!RE("(-?\\d+)").FullMatch("2147483648", &v));
948 CHECK(RE("(\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
949 CHECK(RE("(\\d+)").FullMatch("4294967295", &v)); CHECK_EQ(v, max_value);
950 CHECK(!RE("(\\d+)").FullMatch("4294967296", &v));
966 CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
967 CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100);
970 CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
973 CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value);
978 CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
983 CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
993 CHECK(RE("(-?\\d+)").FullMatch("100",&v)); CHECK_EQ(v, 100);
994 CHECK(RE("(-?\\d+)").FullMatch("-100",&v2)); CHECK_EQ(v2, -100);
997 CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);
1001 CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));
1006 CHECK(RE("(.*)").FullMatch("100", &v));
1007 CHECK(RE("(.*)").FullMatch("-100.", &v));
1008 CHECK(RE("(.*)").FullMatch("1e23", &v));
1012 CHECK(RE("(.*)").FullMatch("100", &v));
1013 CHECK(RE("(.*)").FullMatch("-100.", &v));
1014 CHECK(RE("(.*)").FullMatch("1e23", &v));
1018 CHECK(!RE("(\\d+)").FullMatch("x1001", &i));
1019 CHECK(!RE("(\\d+)").FullMatch("1001x", &i));
1020 CHECK(RE("x(\\d+)").FullMatch("x1001", &i)); CHECK_EQ(i, 1001);
1021 CHECK(RE("(\\d+)x").FullMatch("1001x", &i)); CHECK_EQ(i, 1001);
1024 CHECK(RE("[0-9a-f+.-]{5,}").FullMatch("0abcd"));
1025 CHECK(RE("[0-9a-f+.-]{5,}").FullMatch("0abcde"));
1026 CHECK(!RE("[0-9a-f+.-]{5,}").FullMatch("0abc"));
1028 // Complicated RE
1029 CHECK(RE("foo|bar|[A-Z]").FullMatch("foo"));
1030 CHECK(RE("foo|bar|[A-Z]").FullMatch("bar"));
1031 CHECK(RE("foo|bar|[A-Z]").FullMatch("X"));
1032 CHECK(!RE("foo|bar|[A-Z]").FullMatch("XY"));
1035 CHECK(RE("fo|foo").FullMatch("fo"));
1036 CHECK(RE("fo|foo").FullMatch("foo"));
1037 CHECK(RE("fo|foo$").FullMatch("fo"));
1038 CHECK(RE("fo|foo$").FullMatch("foo"));
1039 CHECK(RE("foo$").FullMatch("foo"));
1040 CHECK(!RE("foo\\$").FullMatch("foo$bar"));
1041 CHECK(!RE("fo|bar").FullMatch("fox"));
1048 CHECK(!RE("foo$").PartialMatch("foo\n"));
1053 CHECK(RE("").FullMatch(""));
1056 CHECK(RE("(\\d){1}").FullMatch("1",
1061 CHECK(RE("(\\d)(\\d)").FullMatch("12",
1067 CHECK(RE("(\\d)(\\d)(\\d)").FullMatch("123",
1074 CHECK(RE("(\\d)(\\d)(\\d)(\\d)").FullMatch("1234",
1082 CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("12345",
1092 CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("123456",
1103 CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)").FullMatch("1234567",
1115 CHECK(RE("(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)"
1143 CHECK(RE("h.*o").PartialMatch("hello"));
1144 CHECK(RE("h.*o").PartialMatch("othello"));
1145 CHECK(RE("h.*o").PartialMatch("hello!"));
1146 CHECK(RE("((((((((((((((((((((x))))))))))))))))))))").PartialMatch("x"));
1161 const RE re(kPattern);
1162 CHECK_EQ(kPattern, re.pattern());
1165 // Check RE error field.
1167 RE re("foo");
1168 CHECK(re.error().empty()); // Must have no error
1191 RE re_test1(".........");
1193 RE re_test2("...", pcrecpp::UTF8());
1199 RE re_test3("(.)");
1202 RE re_test4("(.)", pcrecpp::UTF8());
1207 RE re_test5(utf8_string);
1209 RE re_test6(utf8_string, pcrecpp::UTF8());
1213 RE re_test7(utf8_pattern);
1215 RE re_test8(utf8_pattern, pcrecpp::UTF8());
1225 RE match_sentence(pattern);
1226 RE match_sentence_re(pattern, pcrecpp::UTF8());
1235 RE match_sentence(pattern);
1236 RE match_sentence_re(pattern, pcrecpp::UTF8());
1245 { RE re("a\\1"); CHECK(!re.error().empty()); }
1247 RE re("a[x");
1248 CHECK(!re.error().empty());
1251 RE re("a[z-a]");
1252 CHECK(!re.error().empty());
1255 RE re("a[[:foobar:]]");
1256 CHECK(!re.error().empty());
1259 RE re("a(b");
1260 CHECK(!re.error().empty());
1263 RE re("a\\");
1264 CHECK(!re.error().empty());