Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(3)  |  Derive(0)  |  Import(0)
Replace all instances of the target string with the replacement string.
Works in situ, contra str.replace().

src/s/a/say-1.2.3/test/test_textrange.py   say(Download)
    assert tr.lines == 'a b'.split()
 
    tr.replace('a', 'A')
    assert tr.lines == 'A b'.split()
    assert t.lines == 'a a A b a'.split()
    assert tr.lines == 'a b'.split()
 
    tr.replace({'a': 'A', 'b': 'BEE'})
    assert tr.lines == 'A BEE'.split()
    assert t.lines == 'a a A BEE a'.split()
    assert tr.lines == ['b', 'c']
 
    tr.replace('b', 'B')
    assert tr.lines == ['B', 'c']