[lang-ref] ( regexp_replace_first ) ( python )
def test_regexp_replace_first():
# re.sub(.., count=1)
text = 'abcdefgh abcdefgh abcdefgh'
pattern = r'd.f'
after = 'DEF'
r = re.sub(pattern, after, text, count=1)
assert r == 'abcDEFgh abcdefgh abcdefgh'