Lines Matching +full:- +full:replace
112 self.checkequal(1, 'aaa', 'count', 'a', -1)
113 self.checkequal(3, 'aaa', 'count', 'a', -10)
116 self.checkequal(2, 'aaa', 'count', 'a', 0, -1)
117 self.checkequal(0, 'aaa', 'count', 'a', 0, -10)
121 self.checkequal(2, 'aaa', 'count', '', -1)
122 self.checkequal(4, 'aaa', 'count', '', -10)
155 r2, rem = divmod(n - len(i.replace(j, '')), len(j))
165 self.checkequal(-1, 'abcdefghiabc', 'find', 'def', 4)
169 self.checkequal(-1, 'abc', 'find', '', 4)
174 self.checkequal(-1, 'rrarrrrrrrrra', 'find', 'a', 4, 6)
182 self.checkequal(-1, '', 'find', '', 1, 1)
183 self.checkequal(-1, '', 'find', '', sys.maxint, 0)
185 self.checkequal(-1, '', 'find', 'xx')
186 self.checkequal(-1, '', 'find', 'xx', 1, 1)
187 self.checkequal(-1, '', 'find', 'xx', sys.maxint, 0)
190 self.checkequal(-1, 'ab', 'find', 'xxx', sys.maxsize + 1, 0)
210 r1 = (loc != -1)
213 if loc != -1:
220 self.checkequal(-1, 'abcdefghiabc', 'rfind', 'abcz')
224 self.checkequal(-1, 'abc', 'rfind', '', 4)
229 self.checkequal(-1, 'rrarrrrrrrrra', 'rfind', 'a', 4, 6)
254 r1 = (loc != -1)
257 if loc != -1:
261 self.checkequal(-1, 'ab', 'rfind', 'xxx', sys.maxsize + 1, 0)
272 self.checkraises(ValueError, 'abcdefghi', 'index', 'ghi', -1)
288 self.checkequal(0, 'abcdefghiabc', 'rindex', 'abc', 0, -1)
292 self.checkraises(ValueError, 'defghiabc', 'rindex', 'abc', 0, -1)
294 self.checkraises(ValueError, 'abcdefghi', 'rindex', 'ghi', 0, -1)
343 sys.maxint-1)
376 sys.maxint-2)
386 self.checkequal(['a']*20, ('a|'*20)[:-1], 'split', '|')
388 ('a|'*20)[:-1], 'split', '|', 15)
397 sys.maxint-10)
414 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH')
415 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH', 19)
416 self.checkequal(['a']*18 + ['aBLAHa'], ('aBLAH'*20)[:-4],
442 sys.maxint-20)
462 self.checkequal([aaa[:-4]] + ['a'], aaa, 'rsplit', None, 1)
478 sys.maxint-100)
489 self.checkequal(['a']*20, ('a|'*20)[:-1], 'rsplit', '|')
491 ('a|'*20)[:-1], 'rsplit', '|', 15)
500 sys.maxint-5)
517 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH')
518 self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH', 19)
519 self.checkequal(['aBLAHa'] + ['a']*18, ('aBLAH'*20)[:-4],
624 EQ("", "", "replace", "", "")
625 EQ("A", "", "replace", "", "A")
626 EQ("", "", "replace", "A", "")
627 EQ("", "", "replace", "A", "A")
628 EQ("", "", "replace", "", "", 100)
629 EQ("", "", "replace", "", "", sys.maxint)
632 EQ("A", "A", "replace", "", "")
633 EQ("*A*", "A", "replace", "", "*")
634 EQ("*1A*1", "A", "replace", "", "*1")
635 EQ("*-#A*-#", "A", "replace", "", "*-#")
636 EQ("*-A*-A*-", "AA", "replace", "", "*-")
637 EQ("*-A*-A*-", "AA", "replace", "", "*-", -1)
638 EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxint)
639 EQ("*-A*-A*-", "AA", "replace", "", "*-", 4)
640 EQ("*-A*-A*-", "AA", "replace", "", "*-", 3)
641 EQ("*-A*-A", "AA", "replace", "", "*-", 2)
642 EQ("*-AA", "AA", "replace", "", "*-", 1)
643 EQ("AA", "AA", "replace", "", "*-", 0)
646 EQ("", "A", "replace", "A", "")
647 EQ("", "AAA", "replace", "A", "")
648 EQ("", "AAA", "replace", "A", "", -1)
649 EQ("", "AAA", "replace", "A", "", sys.maxint)
650 EQ("", "AAA", "replace", "A", "", 4)
651 EQ("", "AAA", "replace", "A", "", 3)
652 EQ("A", "AAA", "replace", "A", "", 2)
653 EQ("AA", "AAA", "replace", "A", "", 1)
654 EQ("AAA", "AAA", "replace", "A", "", 0)
655 EQ("", "AAAAAAAAAA", "replace", "A", "")
656 EQ("BCD", "ABACADA", "replace", "A", "")
657 EQ("BCD", "ABACADA", "replace", "A", "", -1)
658 EQ("BCD", "ABACADA", "replace", "A", "", sys.maxint)
659 EQ("BCD", "ABACADA", "replace", "A", "", 5)
660 EQ("BCD", "ABACADA", "replace", "A", "", 4)
661 EQ("BCDA", "ABACADA", "replace", "A", "", 3)
662 EQ("BCADA", "ABACADA", "replace", "A", "", 2)
663 EQ("BACADA", "ABACADA", "replace", "A", "", 1)
664 EQ("ABACADA", "ABACADA", "replace", "A", "", 0)
665 EQ("BCD", "ABCAD", "replace", "A", "")
666 EQ("BCD", "ABCADAA", "replace", "A", "")
667 EQ("BCD", "BCD", "replace", "A", "")
668 EQ("*************", "*************", "replace", "A", "")
669 EQ("^A^", "^"+"A"*1000+"^", "replace", "A", "", 999)
672 EQ("", "the", "replace", "the", "")
673 EQ("ater", "theater", "replace", "the", "")
674 EQ("", "thethe", "replace", "the", "")
675 EQ("", "thethethethe", "replace", "the", "")
676 EQ("aaaa", "theatheatheathea", "replace", "the", "")
677 EQ("that", "that", "replace", "the", "")
678 EQ("thaet", "thaet", "replace", "the", "")
679 EQ("here and re", "here and there", "replace", "the", "")
681 "replace", "the", "", sys.maxint)
683 "replace", "the", "", -1)
685 "replace", "the", "", 3)
687 "replace", "the", "", 2)
689 "replace", "the", "", 1)
691 "replace", "the", "", 0)
692 EQ("here and re and re", "here and there and there", "replace", "the", "")
694 EQ("abc", "abc", "replace", "the", "")
695 EQ("abcdefg", "abcdefg", "replace", "the", "")
698 EQ("bob", "bbobob", "replace", "bob", "")
699 EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "")
700 EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "")
701 EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "")
703 # single character replace in place (len(from)==len(to)==1)
704 EQ("Who goes there?", "Who goes there?", "replace", "o", "o")
705 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O")
706 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxint)
707 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1)
708 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3)
709 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2)
710 EQ("WhO goes there?", "Who goes there?", "replace", "o", "O", 1)
711 EQ("Who goes there?", "Who goes there?", "replace", "o", "O", 0)
713 EQ("Who goes there?", "Who goes there?", "replace", "a", "q")
714 EQ("who goes there?", "Who goes there?", "replace", "W", "w")
715 EQ("wwho goes there?ww", "WWho goes there?WW", "replace", "W", "w")
716 EQ("Who goes there!", "Who goes there?", "replace", "?", "!")
717 EQ("Who goes there!!", "Who goes there??", "replace", "?", "!")
719 EQ("Who goes there?", "Who goes there?", "replace", ".", "!")
721 # substring replace in place (len(from)==len(to) > 1)
722 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**")
723 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxint)
724 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1)
725 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4)
726 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3)
727 EQ("Th** ** a tissue", "This is a tissue", "replace", "is", "**", 2)
728 EQ("Th** is a tissue", "This is a tissue", "replace", "is", "**", 1)
729 EQ("This is a tissue", "This is a tissue", "replace", "is", "**", 0)
730 EQ("cobob", "bobob", "replace", "bob", "cob")
731 EQ("cobobXcobocob", "bobobXbobobob", "replace", "bob", "cob")
732 EQ("bobob", "bobob", "replace", "bot", "bot")
734 # replace single character (len(from)==1, len(to)>1)
735 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK")
736 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1)
737 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxint)
738 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2)
739 EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1)
740 EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0)
741 EQ("A----B----C----", "A.B.C.", "replace", ".", "----")
743 EQ("Reykjavik", "Reykjavik", "replace", "q", "KK")
745 # replace substring (len(from)>1, len(to)!=len(from))
747 "replace", "spam", "ham")
749 "replace", "spam", "ham", sys.maxint)
751 "replace", "spam", "ham", -1)
753 "replace", "spam", "ham", 4)
755 "replace", "spam", "ham", 3)
757 "replace", "spam", "ham", 2)
759 "replace", "spam", "ham", 1)
761 "replace", "spam", "ham", 0)
763 EQ("bobob", "bobobob", "replace", "bobob", "bob")
764 EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob")
765 EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby")
770 EQ("bbc", "abc", "replace", ba, bb)
771 EQ("aac", "abc", "replace", bb, ba)
774 self.checkequal('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1)
775 self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '')
776 self.checkequal('one@two@three!', 'one!two!three!', 'replace', '!', '@', 2)
777 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@', 3)
778 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@', 4)
779 self.checkequal('one!two!three!', 'one!two!three!', 'replace', '!', '@', 0)
780 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@')
781 self.checkequal('one!two!three!', 'one!two!three!', 'replace', 'x', '@')
782 self.checkequal('one!two!three!', 'one!two!three!', 'replace', 'x', '@', 2)
783 self.checkequal('-a-b-c-', 'abc', 'replace', '', '-')
784 self.checkequal('-a-b-c', 'abc', 'replace', '', '-', 3)
785 self.checkequal('abc', 'abc', 'replace', '', '-', 0)
786 self.checkequal('', '', 'replace', '', '')
787 self.checkequal('abc', 'abc', 'replace', 'ab', '--', 0)
788 self.checkequal('abc', 'abc', 'replace', 'xy', '--')
789 # Next three for SF bug 422088: [OSF1 alpha] string.replace(); died with
792 self.checkequal('', '123', 'replace', '123', '')
793 self.checkequal('', '123123', 'replace', '123', '')
794 self.checkequal('x', '123x123', 'replace', '123', '')
796 self.checkraises(TypeError, 'hello', 'replace')
797 self.checkraises(TypeError, 'hello', 'replace', 42)
798 self.checkraises(TypeError, 'hello', 'replace', 42, 'h')
799 self.checkraises(TypeError, 'hello', 'replace', 'h', 42)
802 'only applies to 32-bit platforms')
806 self.checkraises(OverflowError, A2_16, "replace", "", A2_16)
807 self.checkraises(OverflowError, A2_16, "replace", "A", A2_16)
808 self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16)
817 self.checkequal('-123', '-123', 'zfill', 3)
818 self.checkequal('-123', '-123', 'zfill', 4)
819 self.checkequal('-0123', '-123', 'zfill', 5)
861 self.checkequal(False, 'Not--a Titlecase String', 'istitle')
911 self.checkequal('Format,This-As*Title;String', "fOrMaT,thIs-aS*titLe;String", 'title', )
948 self.checkequal(True, 'hello', 'startswith', 'he', 0, -1)
949 self.checkequal(True, 'hello', 'startswith', 'he', -53, -1)
950 self.checkequal(False, 'hello', 'startswith', 'hello', 0, -1)
951 self.checkequal(False, 'hello', 'startswith', 'hello world', -1, -10)
952 self.checkequal(False, 'hello', 'startswith', 'ello', -5)
953 self.checkequal(True, 'hello', 'startswith', 'ello', -4)
954 self.checkequal(False, 'hello', 'startswith', 'o', -2)
955 self.checkequal(True, 'hello', 'startswith', 'o', -1)
956 self.checkequal(True, 'hello', 'startswith', '', -3, -3)
957 self.checkequal(False, 'hello', 'startswith', 'lo', -9)
971 self.checkequal(True, 'hello', 'startswith', ('lo', 'he'), 0, -1)
994 self.checkequal(True, 'hello', 'endswith', 'lo', -2)
995 self.checkequal(False, 'hello', 'endswith', 'he', -2)
996 self.checkequal(True, 'hello', 'endswith', '', -3, -3)
997 self.checkequal(False, 'hello', 'endswith', 'hello world', -10, -2)
998 self.checkequal(False, 'helloworld', 'endswith', 'worl', -6)
999 self.checkequal(True, 'helloworld', 'endswith', 'worl', -5, -1)
1000 self.checkequal(True, 'helloworld', 'endswith', 'worl', -5, 9)
1001 self.checkequal(True, 'helloworld', 'endswith', 'world', -7, 12)
1002 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -99, -3)
1003 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -8, -3)
1004 self.checkequal(True, 'helloworld', 'endswith', 'lowo', -7, -3)
1005 self.checkequal(False, 'helloworld', 'endswith', 'lowo', 3, -4)
1006 self.checkequal(False, 'helloworld', 'endswith', 'lowo', -8, -2)
1019 'rld'), 3, -1)
1020 self.checkequal(True, 'hello', 'endswith', ('hell', 'ell'), 0, -1)
1039 self.checkequal(u'c', 'abc', '__getitem__', -1)
1064 indices = (0, None, 1, 3, 41, -1, -2, -37)
1074 self.checkequal('', 'abc', '__mul__', -1)
1080 # XXX: on a 64-bit system, this doesn't raise an overflow error,
1103 self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
1105 self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
1135 for ordinal in (-100, 0x200000):
1141 if slongvalue[-1] in ("L","l"): slongvalue = slongvalue[:-1]
1179 SIZE_MAX = (1 << (PY_SSIZE_T_MAX.bit_length() + 1)) - 1
1204 # Check that strings don't copy and modify cached single-character strings
1210 self.checkequal('a', 'A', 'replace', 'A', 'a')
1262 self.checkequal(3, s, 'find', 'l', -2, None)
1263 self.checkequal(2, s, 'find', 'l', None, -2)
1267 self.checkequal(3, s, 'rfind', 'l', -2, None)
1268 self.checkequal(2, s, 'rfind', 'l', None, -2)
1272 self.checkequal(3, s, 'index', 'l', -2, None)
1273 self.checkequal(2, s, 'index', 'l', None, -2)
1277 self.checkequal(3, s, 'rindex', 'l', -2, None)
1278 self.checkequal(2, s, 'rindex', 'l', None, -2)
1282 self.checkequal(1, s, 'count', 'l', -2, None)
1283 self.checkequal(1, s, 'count', 'l', None, -2)
1287 self.checkequal(True, s, 'endswith', 'lo', -2, None)
1288 self.checkequal(True, s, 'endswith', 'l', None, -2)
1292 self.checkequal(True, s, 'startswith', 'l', -2, None)
1293 self.checkequal(True, s, 'startswith', 'h', None, -2)
1321 ''.join(map(chr, xrange(256))).replace('abc', 'xyz'),
1392 # Should also test mixed-type join.