• Home
  • Raw
  • Download

Lines Matching full:replace

155                     r2, rem = divmod(n - len(i.replace(j, '')), len(j))
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)
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)
1210 self.checkequal('a', 'A', 'replace', 'A', 'a')
1321 ''.join(map(chr, xrange(256))).replace('abc', 'xyz'),