• Home
  • Raw
  • Download

Lines Matching refs:match

39         self.assertEqual(re.match('a*', 'xxx').span(0), (0, 0))
40 self.assertEqual(re.match('a*', 'xxx').span(), (0, 0))
41 self.assertEqual(re.match('x*', 'xxxa').span(0), (0, 3))
42 self.assertEqual(re.match('x*', 'xxxa').span(), (0, 3))
43 self.assertIsNone(re.match('a+', 'xxx'))
124 self.assertRaises(ValueError, re.match, pattern, 'A', re.I)
284 self.assertEqual(re.match('a', 'a').groups(), ())
285 self.assertEqual(re.match('(a)', 'a').groups(), ('a',))
286 self.assertEqual(re.match(r'(a)', 'a').group(0), 'a')
287 self.assertEqual(re.match(r'(a)', 'a').group(1), 'a')
288 self.assertEqual(re.match(r'(a)', 'a').group(1, 1), ('a', 'a'))
291 self.assertEqual(pat.match('a').groups(), ('a', 'a', None, None))
292 self.assertEqual(pat.match('b').groups(), ('b', None, 'b', None))
293 self.assertEqual(pat.match('ac').groups(), ('a', 'a', None, 'c'))
294 self.assertEqual(pat.match('bc').groups(), ('b', None, 'b', 'c'))
295 self.assertEqual(pat.match('bc').groups(""), ('b', "", 'b', 'c'))
298 m = re.match('(a)', 'a')
305 self.assertEqual(pat.match('a').group(1, 2, 3), ('a', None, None))
306 self.assertEqual(pat.match('b').group('a1', 'b2', 'c3'),
308 self.assertEqual(pat.match('ac').group(1, 'b2', 3), ('a', None, 'c'))
311 self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', '(a)').groups(),
313 self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', 'a').groups(),
315 self.assertIsNone(re.match('^(\()?([^()]+)(?(1)\))$', 'a)'))
316 self.assertIsNone(re.match('^(\()?([^()]+)(?(1)\))$', '(a'))
317 self.assertEqual(re.match('^(?:(a)|c)((?(1)b|d))$', 'ab').groups(),
319 self.assertEqual(re.match('^(?:(a)|c)((?(1)b|d))$', 'cd').groups(),
321 self.assertEqual(re.match('^(?:(a)|c)((?(1)|d))$', 'cd').groups(),
323 self.assertEqual(re.match('^(?:(a)|c)((?(1)|d))$', 'a').groups(),
328 self.assertEqual(p.match('abc').groups(),
330 self.assertEqual(p.match('ad').groups(),
332 self.assertIsNone(p.match('abd'))
333 self.assertIsNone(p.match('ac'))
337 self.assertEqual(re.match(r'^(\|)?([^()]+)\1$', '|a|').groups(),
339 self.assertEqual(re.match(r'^(\|)?([^()]+)\1?$', 'a').groups(),
341 self.assertIsNone(re.match(r'^(\|)?([^()]+)\1$', 'a|'))
342 self.assertIsNone(re.match(r'^(\|)?([^()]+)\1$', '|a'))
343 self.assertEqual(re.match(r'^(?:(a)|c)(\1)$', 'aa').groups(),
345 self.assertEqual(re.match(r'^(?:(a)|c)(\1)?$', 'c').groups(),
349 self.assertEqual(re.match('(?P<first>first) (?P<second>second)',
354 self.assertEqual(re.match("(?P<first>first) (?P<second>second)",
360 self.assertIsNone(re.match("^(\w){1}$", "abc"))
361 self.assertIsNone(re.match("^(\w){1}?$", "abc"))
362 self.assertIsNone(re.match("^(\w){1,2}$", "abc"))
363 self.assertIsNone(re.match("^(\w){1,2}?$", "abc"))
365 self.assertEqual(re.match("^(\w){3}$", "abc").group(1), "c")
366 self.assertEqual(re.match("^(\w){1,3}$", "abc").group(1), "c")
367 self.assertEqual(re.match("^(\w){1,4}$", "abc").group(1), "c")
368 self.assertEqual(re.match("^(\w){3,4}?$", "abc").group(1), "c")
369 self.assertEqual(re.match("^(\w){3}?$", "abc").group(1), "c")
370 self.assertEqual(re.match("^(\w){1,3}?$", "abc").group(1), "c")
371 self.assertEqual(re.match("^(\w){1,4}?$", "abc").group(1), "c")
372 self.assertEqual(re.match("^(\w){3,4}?$", "abc").group(1), "c")
374 self.assertIsNone(re.match("^x{1}$", "xxx"))
375 self.assertIsNone(re.match("^x{1}?$", "xxx"))
376 self.assertIsNone(re.match("^x{1,2}$", "xxx"))
377 self.assertIsNone(re.match("^x{1,2}?$", "xxx"))
379 self.assertTrue(re.match("^x{3}$", "xxx"))
380 self.assertTrue(re.match("^x{1,3}$", "xxx"))
381 self.assertTrue(re.match("^x{1,4}$", "xxx"))
382 self.assertTrue(re.match("^x{3,4}?$", "xxx"))
383 self.assertTrue(re.match("^x{3}?$", "xxx"))
384 self.assertTrue(re.match("^x{1,3}?$", "xxx"))
385 self.assertTrue(re.match("^x{1,4}?$", "xxx"))
386 self.assertTrue(re.match("^x{3,4}?$", "xxx"))
388 self.assertIsNone(re.match("^x{}$", "xxx"))
389 self.assertTrue(re.match("^x{}$", "x{}"))
392 self.assertEqual(re.match("(a)", "a").pos, 0)
393 self.assertEqual(re.match("(a)", "a").endpos, 1)
394 self.assertEqual(re.match("(a)", "a").string, "a")
395 self.assertEqual(re.match("(a)", "a").regs, ((0, 1), (0, 1)))
396 self.assertTrue(re.match("(a)", "a").re)
432 self.assertEqual(re.match(r"\(", '(').group(), '(')
433 self.assertIsNone(re.match(r"\(", ')'))
434 self.assertEqual(re.match(r"\\", '\\').group(), '\\')
435 self.assertEqual(re.match(r"[\]]", ']').group(), ']')
436 self.assertIsNone(re.match(r"[\]]", '['))
437 self.assertEqual(re.match(r"[a\-c]", '-').group(), '-')
438 self.assertIsNone(re.match(r"[a\-c]", 'b'))
439 self.assertEqual(re.match(r"[\^a]+", 'a^').group(), 'a^')
440 self.assertIsNone(re.match(r"[\^a]+", 'b'))
445 self.assertEqual(re.match('\\%c$' % c, c).group(), c)
446 self.assertIsNone(re.match('\\%c' % c, 'a'))
450 self.assertEqual(re.match('[\\%c]$' % c, c).group(), c)
451 self.assertIsNone(re.match('[\\%c]' % c, 'a'))
458 self.assertTrue(re.match(r"\b", "abc"))
462 self.assertFalse(re.match(r"\B", "abc"))
481 self.assertEqual(re.match(u(r"([\u2222\u2223])"),
483 self.assertEqual(re.match(u(r"([\u2222\u2223])"),
486 self.assertEqual(re.match(r, unichr(0xff01), re.UNICODE).group(), unichr(0xff01))
491 self.assertTrue(r.match('1000'))
492 self.assertTrue(r.match('9999'))
495 self.assertEqual(re.match("a.b", "a\nb", re.DOTALL).group(0),
497 self.assertEqual(re.match("a.*b", "a\n\nb", re.DOTALL).group(0),
501 self.assertEqual(re.match("(a(?=\s[^a]))", "a b").group(1), "a")
502 self.assertEqual(re.match("(a(?=\s[^a]*))", "a b").group(1), "a")
503 self.assertEqual(re.match("(a(?=\s[abc]))", "a b").group(1), "a")
504 self.assertEqual(re.match("(a(?=\s[abc]*))", "a bc").group(1), "a")
505 self.assertEqual(re.match(r"(a)(?=\s\1)", "a a").group(1), "a")
506 self.assertEqual(re.match(r"(a)(?=\s\1*)", "a aa").group(1), "a")
507 self.assertEqual(re.match(r"(a)(?=\s(abc|a))", "a a").group(1), "a")
509 self.assertEqual(re.match(r"(a(?!\s[^a]))", "a a").group(1), "a")
510 self.assertEqual(re.match(r"(a(?!\s[abc]))", "a d").group(1), "a")
511 self.assertEqual(re.match(r"(a)(?!\s\1)", "a b").group(1), "a")
512 self.assertEqual(re.match(r"(a)(?!\s(abc|a))", "a b").group(1), "a")
515 self.assertTrue(re.match(r'(a)b(?=\1)a', 'aba'))
516 self.assertIsNone(re.match(r'(a)b(?=\1)c', 'abac'))
518 self.assertTrue(re.match(r'(?P<g>a)b(?=(?P=g))a', 'aba'))
519 self.assertIsNone(re.match(r'(?P<g>a)b(?=(?P=g))c', 'abac'))
521 self.assertTrue(re.match(r'(?:(a)|(x))b(?=(?(2)x|c))c', 'abc'))
522 self.assertIsNone(re.match(r'(?:(a)|(x))b(?=(?(2)c|x))c', 'abc'))
523 self.assertTrue(re.match(r'(?:(a)|(x))b(?=(?(2)x|c))c', 'abc'))
524 self.assertIsNone(re.match(r'(?:(a)|(x))b(?=(?(1)b|x))c', 'abc'))
525 self.assertTrue(re.match(r'(?:(a)|(x))b(?=(?(1)c|x))c', 'abc'))
527 self.assertTrue(re.match(r'(a)b(?=(?(2)x|c))(c)', 'abc'))
528 self.assertIsNone(re.match(r'(a)b(?=(?(2)b|x))(c)', 'abc'))
529 self.assertTrue(re.match(r'(a)b(?=(?(1)c|x))(c)', 'abc'))
532 self.assertTrue(re.match(r'ab(?<=b)c', 'abc'))
533 self.assertIsNone(re.match(r'ab(?<=c)c', 'abc'))
534 self.assertIsNone(re.match(r'ab(?<!b)c', 'abc'))
535 self.assertTrue(re.match(r'ab(?<!c)c', 'abc'))
550 self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
551 self.assertEqual(re.match("abc", u"ABC", re.I).group(0), "ABC")
552 self.assertEqual(re.match(r"(a\s[^a])", "a b", re.I).group(1), "a b")
553 self.assertEqual(re.match(r"(a\s[^a]*)", "a bb", re.I).group(1), "a bb")
554 self.assertEqual(re.match(r"(a\s[abc])", "a b", re.I).group(1), "a b")
555 self.assertEqual(re.match(r"(a\s[abc]*)", "a bb", re.I).group(1), "a bb")
556 self.assertEqual(re.match(r"((a)\s\2)", "a a", re.I).group(1), "a a")
557 self.assertEqual(re.match(r"((a)\s\2*)", "a aa", re.I).group(1), "a aa")
558 self.assertEqual(re.match(r"((a)\s(abc|a))", "a a", re.I).group(1), "a a")
559 self.assertEqual(re.match(r"((a)\s(abc|a)*)", "a aa", re.I).group(1), "a aa")
563 self.assertTrue(re.match(ur'K', u(r'\u212a'), re.U | re.I))
564 self.assertTrue(re.match(ur'k', u(r'\u212a'), re.U | re.I))
565 self.assertTrue(re.match(u(r'\u212a'), u'K', re.U | re.I))
566 self.assertTrue(re.match(u(r'\u212a'), u'k', re.U | re.I))
568 self.assertTrue(re.match(ur'S', u(r'\u017f'), re.U | re.I))
569 self.assertTrue(re.match(ur's', u(r'\u017f'), re.U | re.I))
570 self.assertTrue(re.match(u(r'\u017f'), u'S', re.U | re.I))
571 self.assertTrue(re.match(u(r'\u017f'), u's', re.U | re.I))
574 self.assertTrue(re.match(r'[19A]', 'A', re.I))
575 self.assertTrue(re.match(r'[19a]', 'a', re.I))
576 self.assertTrue(re.match(r'[19a]', 'A', re.I))
577 self.assertTrue(re.match(r'[19A]', 'a', re.I))
579 self.assertTrue(re.match(ur'[19A]', u'A', re.U | re.I))
580 self.assertTrue(re.match(ur'[19a]', u'a', re.U | re.I))
581 self.assertTrue(re.match(ur'[19a]', u'A', re.U | re.I))
582 self.assertTrue(re.match(ur'[19A]', u'a', re.U | re.I))
584 self.assertTrue(re.match(u(r'[19K]'), u(r'\u212a'), re.U | re.I))
585 self.assertTrue(re.match(u(r'[19k]'), u(r'\u212a'), re.U | re.I))
586 self.assertTrue(re.match(u(r'[19\u212a]'), u'K', re.U | re.I))
587 self.assertTrue(re.match(u(r'[19\u212a]'), u'k', re.U | re.I))
589 self.assertTrue(re.match(ur'[19S]', u(r'\u017f'), re.U | re.I))
590 self.assertTrue(re.match(ur'[19s]', u(r'\u017f'), re.U | re.I))
591 self.assertTrue(re.match(u(r'[19\u017f]'), u'S', re.U | re.I))
592 self.assertTrue(re.match(u(r'[19\u017f]'), u's', re.U | re.I))
596 self.assertTrue(re.match(r'[9-a]', '_', re.I))
597 self.assertIsNone(re.match(r'[9-A]', '_', re.I))
598 self.assertTrue(re.match(r'[\xc0-\xde]', '\xd7', re.I))
599 self.assertIsNone(re.match(r'[\xc0-\xde]', '\xf7', re.I))
600 self.assertTrue(re.match(r'[\xe0-\xfe]', '\xf7',re.I))
601 self.assertIsNone(re.match(r'[\xe0-\xfe]', '\xd7', re.I))
603 self.assertTrue(re.match(u(r'[9-a]'), u(r'_'), re.U | re.I))
604 self.assertIsNone(re.match(u(r'[9-A]'), u(r'_'), re.U | re.I))
605 self.assertTrue(re.match(u(r'[\xc0-\xde]'),
607 self.assertIsNone(re.match(u(r'[\xc0-\xde]'),
609 self.assertTrue(re.match(u(r'[\xe0-\xfe]'),
611 self.assertIsNone(re.match(u(r'[\xe0-\xfe]'),
613 self.assertTrue(re.match(u(r'[\u0430-\u045f]'),
615 self.assertTrue(re.match(u(r'[\u0430-\u045f]'),
617 self.assertTrue(re.match(u(r'[\u0400-\u042f]'),
619 self.assertTrue(re.match(u(r'[\u0400-\u042f]'),
622 self.assertTrue(re.match(u(r'[\U00010428-\U0001044f]'),
624 self.assertTrue(re.match(u(r'[\U00010428-\U0001044f]'),
626 self.assertTrue(re.match(u(r'[\U00010400-\U00010427]'),
628 self.assertTrue(re.match(u(r'[\U00010400-\U00010427]'),
632 self.assertTrue(re.match(ur'[J-M]', u(r'\u212a'), re.U | re.I))
633 self.assertTrue(re.match(ur'[j-m]', u(r'\u212a'), re.U | re.I))
634 self.assertTrue(re.match(u(r'[\u2129-\u212b]'), u'K', re.U | re.I))
635 self.assertTrue(re.match(u(r'[\u2129-\u212b]'), u'k', re.U | re.I))
637 self.assertTrue(re.match(ur'[R-T]', u(r'\u017f'), re.U | re.I))
638 self.assertTrue(re.match(ur'[r-t]', u(r'\u017f'), re.U | re.I))
639 self.assertTrue(re.match(u(r'[\u017e-\u0180]'), u'S', re.U | re.I))
640 self.assertTrue(re.match(u(r'[\u017e-\u0180]'), u's', re.U | re.I))
643 self.assertEqual(re.match(r"(\s)", " ").group(1), " ")
652 self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
653 self.assertEqual(re.match("abc", u"ABC", re.I).group(0), "ABC")
663 def assertMatch(self, pattern, text, match=None, span=None, argument
664 matcher=re.match):
665 if match is None and span is None:
667 match = text
669 elif match is None or span is None:
674 self.assertEqual(m.group(), match)
752 self.assertTrue(re.match(r"\%03o" % i, chr(i)))
753 self.assertTrue(re.match(r"\%03o0" % i, chr(i)+"0"))
754 self.assertTrue(re.match(r"\%03o8" % i, chr(i)+"8"))
755 self.assertTrue(re.match(r"\x%02x" % i, chr(i)))
756 self.assertTrue(re.match(r"\x%02x0" % i, chr(i)+"0"))
757 self.assertTrue(re.match(r"\x%02xz" % i, chr(i)+"z"))
758 self.assertRaises(re.error, re.match, "\911", "")
762 self.assertTrue(re.match(r"[\%03o]" % i, chr(i)))
763 self.assertTrue(re.match(r"[\%03o0]" % i, chr(i)))
764 self.assertTrue(re.match(r"[\%03o8]" % i, chr(i)))
765 self.assertTrue(re.match(r"[\x%02x]" % i, chr(i)))
766 self.assertTrue(re.match(r"[\x%02x0]" % i, chr(i)))
767 self.assertTrue(re.match(r"[\x%02xz]" % i, chr(i)))
768 self.assertRaises(re.error, re.match, "[\911]", "")
771 self.assertEqual(re.match(r'(a)|(b)', 'b').start(1), -1)
772 self.assertEqual(re.match(r'(a)|(b)', 'b').end(1), -1)
773 self.assertEqual(re.match(r'(a)|(b)', 'b').span(1), (-1, -1))
777 self.assertIsNone(re.match(r'(a)?a','a').lastindex)
778 self.assertEqual(re.match(r'(a)(b)?b','ab').lastindex, 1)
779 self.assertEqual(re.match(r'(?P<a>a)(?P<b>b)?b','ab').lastgroup, 'a')
780 self.assertEqual(re.match("(?P<a>a(b))", "ab").lastgroup, 'a')
781 self.assertEqual(re.match("((a))", "a").lastindex, 1)
792 self.assertEqual(re.match('.*?c', 10000*'ab'+'cd').end(0), 20001)
793 self.assertEqual(re.match('.*?cd', 5000*'ab'+'c'+5000*'ab'+'cde').end(0),
795 self.assertEqual(re.match('.*?cd', 20000*'abc'+'de').end(0), 60001)
808 self.assertEqual(re.match('(x)*', 50000*'x').group(1), 'x')
809 self.assertEqual(re.match('(x)*y', 50000*'x'+'y').group(1), 'x')
810 self.assertEqual(re.match('(x)*?y', 50000*'x'+'y').group(1), 'x')
814 self.assertIsNone(re.match(r'(?:a?)*y', 'z'))
815 self.assertIsNone(re.match(r'(?:a?)+y', 'z'))
816 self.assertIsNone(re.match(r'(?:a?){2,}y', 'z'))
817 self.assertIsNone(re.match(r'(?:a?)*?y', 'z'))
818 self.assertIsNone(re.match(r'(?:a?)+?y', 'z'))
819 self.assertIsNone(re.match(r'(?:a?){2,}?y', 'z'))
845 self.assertEqual(re.match(r'((.%s):)?z'%op, 'z').groups(),
847 self.assertEqual(re.match(r'((.%s):)?z'%op, 'a:z').groups(),
852 self.assertEqual(re.match('^((a)|b)*', 'abc').groups(),
854 self.assertEqual(re.match('^(([ab])|c)*', 'abc').groups(),
856 self.assertEqual(re.match('^((d)|[ab])*', 'abc').groups(),
858 self.assertEqual(re.match('^((a)c|[ab])*', 'abc').groups(),
860 self.assertEqual(re.match('^((a)|b)*?c', 'abc').groups(),
862 self.assertEqual(re.match('^(([ab])|c)*?d', 'abcd').groups(),
864 self.assertEqual(re.match('^((d)|[ab])*?c', 'abc').groups(),
866 self.assertEqual(re.match('^((a)c|[ab])*?c', 'abc').groups(),
871 self.assertEqual(re.match('(a)(?:(?=(b)*)c)*', 'abb').groups(),
873 self.assertEqual(re.match('(a)((?!(b)*))*', 'abb').groups(),
881 self.assertIsNone(pat.match("xyz"))
925 self.assertEqual(re.match('^\d$', x, re.UNICODE).group(0), x)
934 self.assertIsNone(re.match('^\d$', x, re.UNICODE))
944 self.assertIsNone(re.compile("bla").match(a))
945 self.assertEqual(re.compile("").match(a).groups(), ())
954 q = p.match(lower_char)
958 q = p.match(upper_char)
962 q = p.match(lower_char)
966 q = p.match(upper_char)
970 q = p.match(lower_char)
974 q = p.match(upper_char)
977 self.assertTrue(re.match('(?ixu) ' + upper_char, lower_char))
978 self.assertTrue(re.match('(?ixu) ' + lower_char, upper_char))
1056 self.assertEqual(re.match(r".{65535}", string).span(), (0, 65535))
1057 self.assertEqual(re.match(r".{,65535}", string).span(), (0, 65535))
1058 self.assertEqual(re.match(r".{65535,}?", string).span(), (0, 65535))
1059 self.assertEqual(re.match(r".{65536}", string).span(), (0, 65536))
1060 self.assertEqual(re.match(r".{,65536}", string).span(), (0, 65536))
1061 self.assertEqual(re.match(r".{65536,}?", string).span(), (0, 65536))
1075 self.assertIsNone(re.match(r".{%d}" % (MAXREPEAT - 1), string))
1076 self.assertEqual(re.match(r".{,%d}" % (MAXREPEAT - 1), string).span(),
1078 self.assertIsNone(re.match(r".{%d,}?" % (MAXREPEAT - 1), string))
1110 m = r.match("xyyzy")
1148 pat.match(string='abracadabra', pos=7, endpos=10).span(), (7, 9))
1158 self.assertEqual(re.match("(foo)", "foo").group(1L), "foo")
1159 self.assertRaises(IndexError, re.match("", "").group, sys.maxint + 1)
1181 self.assertTrue(re.match(b'\xc5\xe5', b'\xc5\xe5', re.L|re.I))
1182 self.assertTrue(re.match(b'\xc5', b'\xe5', re.L|re.I))
1183 self.assertTrue(re.match(b'\xe5', b'\xc5', re.L|re.I))
1184 self.assertTrue(re.match(b'(?Li)\xc5\xe5', b'\xc5\xe5'))
1185 self.assertTrue(re.match(b'(?Li)\xc5', b'\xe5'))
1186 self.assertTrue(re.match(b'(?Li)\xe5', b'\xc5'))
1190 self.assertTrue(re.match(b'\xc5\xe5', b'\xc5\xe5', re.L|re.I))
1191 self.assertIsNone(re.match(b'\xc5', b'\xe5', re.L|re.I))
1192 self.assertIsNone(re.match(b'\xe5', b'\xc5', re.L|re.I))
1193 self.assertTrue(re.match(b'(?Li)\xc5\xe5', b'\xc5\xe5'))
1194 self.assertIsNone(re.match(b'(?Li)\xc5', b'\xe5'))
1195 self.assertIsNone(re.match(b'(?Li)\xe5', b'\xc5'))