[lang-ref] ( replace_first_with_regexp ) ( python )
def test_replace_first_with_regexp():
# re.sub + count
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, count=1)
assert text_new == 'abc !!DEF!! ghi\nabc def ghi'