[lang-ref] ( replace_all_with_regexp ) ( python )

def test_replace_all_with_regexp():
    # re.sub(p, new, org)
    import re
    text_org = 'abc def ghi\nabc def ghi'
    pattern = 'd.f'
    s_new  = '!!DEF!!'

    text_new = re.sub(pattern, s_new, text_org)

    assert text_new == 'abc !!DEF!! ghi\nabc !!DEF!! ghi'