Lines Matching full:replace
151 r2, rem = divmod(n - len(i.replace(j, self.fixtype(''))),
503 EQ("", "", "replace", "", "")
504 EQ("A", "", "replace", "", "A")
505 EQ("", "", "replace", "A", "")
506 EQ("", "", "replace", "A", "A")
507 EQ("", "", "replace", "", "", 100)
508 EQ("", "", "replace", "", "", sys.maxsize)
511 EQ("A", "A", "replace", "", "")
512 EQ("*A*", "A", "replace", "", "*")
513 EQ("*1A*1", "A", "replace", "", "*1")
514 EQ("*-#A*-#", "A", "replace", "", "*-#")
515 EQ("*-A*-A*-", "AA", "replace", "", "*-")
516 EQ("*-A*-A*-", "AA", "replace", "", "*-", -1)
517 EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxsize)
518 EQ("*-A*-A*-", "AA", "replace", "", "*-", 4)
519 EQ("*-A*-A*-", "AA", "replace", "", "*-", 3)
520 EQ("*-A*-A", "AA", "replace", "", "*-", 2)
521 EQ("*-AA", "AA", "replace", "", "*-", 1)
522 EQ("AA", "AA", "replace", "", "*-", 0)
525 EQ("", "A", "replace", "A", "")
526 EQ("", "AAA", "replace", "A", "")
527 EQ("", "AAA", "replace", "A", "", -1)
528 EQ("", "AAA", "replace", "A", "", sys.maxsize)
529 EQ("", "AAA", "replace", "A", "", 4)
530 EQ("", "AAA", "replace", "A", "", 3)
531 EQ("A", "AAA", "replace", "A", "", 2)
532 EQ("AA", "AAA", "replace", "A", "", 1)
533 EQ("AAA", "AAA", "replace", "A", "", 0)
534 EQ("", "AAAAAAAAAA", "replace", "A", "")
535 EQ("BCD", "ABACADA", "replace", "A", "")
536 EQ("BCD", "ABACADA", "replace", "A", "", -1)
537 EQ("BCD", "ABACADA", "replace", "A", "", sys.maxsize)
538 EQ("BCD", "ABACADA", "replace", "A", "", 5)
539 EQ("BCD", "ABACADA", "replace", "A", "", 4)
540 EQ("BCDA", "ABACADA", "replace", "A", "", 3)
541 EQ("BCADA", "ABACADA", "replace", "A", "", 2)
542 EQ("BACADA", "ABACADA", "replace", "A", "", 1)
543 EQ("ABACADA", "ABACADA", "replace", "A", "", 0)
544 EQ("BCD", "ABCAD", "replace", "A", "")
545 EQ("BCD", "ABCADAA", "replace", "A", "")
546 EQ("BCD", "BCD", "replace", "A", "")
547 EQ("*************", "*************", "replace", "A", "")
548 EQ("^A^", "^"+"A"*1000+"^", "replace", "A", "", 999)
551 EQ("", "the", "replace", "the", "")
552 EQ("ater", "theater", "replace", "the", "")
553 EQ("", "thethe", "replace", "the", "")
554 EQ("", "thethethethe", "replace", "the", "")
555 EQ("aaaa", "theatheatheathea", "replace", "the", "")
556 EQ("that", "that", "replace", "the", "")
557 EQ("thaet", "thaet", "replace", "the", "")
558 EQ("here and re", "here and there", "replace", "the", "")
560 "replace", "the", "", sys.maxsize)
562 "replace", "the", "", -1)
564 "replace", "the", "", 3)
566 "replace", "the", "", 2)
568 "replace", "the", "", 1)
570 "replace", "the", "", 0)
571 EQ("here and re and re", "here and there and there", "replace", "the", "")
573 EQ("abc", "abc", "replace", "the", "")
574 EQ("abcdefg", "abcdefg", "replace", "the", "")
577 EQ("bob", "bbobob", "replace", "bob", "")
578 EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "")
579 EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "")
580 EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "")
582 # single character replace in place (len(from)==len(to)==1)
583 EQ("Who goes there?", "Who goes there?", "replace", "o", "o")
584 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O")
585 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxsize)
586 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1)
587 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3)
588 EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2)
589 EQ("WhO goes there?", "Who goes there?", "replace", "o", "O", 1)
590 EQ("Who goes there?", "Who goes there?", "replace", "o", "O", 0)
592 EQ("Who goes there?", "Who goes there?", "replace", "a", "q")
593 EQ("who goes there?", "Who goes there?", "replace", "W", "w")
594 EQ("wwho goes there?ww", "WWho goes there?WW", "replace", "W", "w")
595 EQ("Who goes there!", "Who goes there?", "replace", "?", "!")
596 EQ("Who goes there!!", "Who goes there??", "replace", "?", "!")
598 EQ("Who goes there?", "Who goes there?", "replace", ".", "!")
600 # substring replace in place (len(from)==len(to) > 1)
601 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**")
602 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxsize)
603 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1)
604 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4)
605 EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3)
606 EQ("Th** ** a tissue", "This is a tissue", "replace", "is", "**", 2)
607 EQ("Th** is a tissue", "This is a tissue", "replace", "is", "**", 1)
608 EQ("This is a tissue", "This is a tissue", "replace", "is", "**", 0)
609 EQ("cobob", "bobob", "replace", "bob", "cob")
610 EQ("cobobXcobocob", "bobobXbobobob", "replace", "bob", "cob")
611 EQ("bobob", "bobob", "replace", "bot", "bot")
613 # replace single character (len(from)==1, len(to)>1)
614 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK")
615 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1)
616 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxsize)
617 EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2)
618 EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1)
619 EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0)
620 EQ("A----B----C----", "A.B.C.", "replace", ".", "----")
622 EQ('...\u043c......<', '...\u043c......<', "replace", "<", "<")
624 EQ("Reykjavik", "Reykjavik", "replace", "q", "KK")
626 # replace substring (len(from)>1, len(to)!=len(from))
628 "replace", "spam", "ham")
630 "replace", "spam", "ham", sys.maxsize)
632 "replace", "spam", "ham", -1)
634 "replace", "spam", "ham", 4)
636 "replace", "spam", "ham", 3)
638 "replace", "spam", "ham", 2)
640 "replace", "spam", "ham", 1)
642 "replace", "spam", "ham", 0)
644 EQ("bobob", "bobobob", "replace", "bobob", "bob")
645 EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob")
646 EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby")
648 self.checkequal('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1)
649 self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '')
650 self.checkequal('one@two@three!', 'one!two!three!', 'replace', '!', '@', 2)
651 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@', 3)
652 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@', 4)
653 self.checkequal('one!two!three!', 'one!two!three!', 'replace', '!', '@', 0)
654 self.checkequal('one@two@three@', 'one!two!three!', 'replace', '!', '@')
655 self.checkequal('one!two!three!', 'one!two!three!', 'replace', 'x', '@')
656 self.checkequal('one!two!three!', 'one!two!three!', 'replace', 'x', '@', 2)
657 self.checkequal('-a-b-c-', 'abc', 'replace', '', '-')
658 self.checkequal('-a-b-c', 'abc', 'replace', '', '-', 3)
659 self.checkequal('abc', 'abc', 'replace', '', '-', 0)
660 self.checkequal('', '', 'replace', '', '')
661 self.checkequal('abc', 'abc', 'replace', 'ab', '--', 0)
662 self.checkequal('abc', 'abc', 'replace', 'xy', '--')
663 # Next three for SF bug 422088: [OSF1 alpha] string.replace(); died with
666 self.checkequal('', '123', 'replace', '123', '')
667 self.checkequal('', '123123', 'replace', '123', '')
668 self.checkequal('x', '123x123', 'replace', '123', '')
670 self.checkraises(TypeError, 'hello', 'replace')
671 self.checkraises(TypeError, 'hello', 'replace', 42)
672 self.checkraises(TypeError, 'hello', 'replace', 42, 'h')
673 self.checkraises(TypeError, 'hello', 'replace', 'h', 42)
680 self.checkraises(OverflowError, A2_16, "replace", "", A2_16)
681 self.checkraises(OverflowError, A2_16, "replace", "A", A2_16)
682 self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16)
1277 self.checkequal('a', 'A', 'replace', 'A', 'a')