fork download
  1. import re
  2. aa='''123456
  3. $SETGLOBAL AAAA
  4. BBBBBB
  5. $SETGLOBAL TTTT'''
  6. text="CCCC"
  7. print(re.sub(r"(\$SETGLOBAL\s+)\w+", r"\1{}".format(text), aa, 1))
  8.  
Success #stdin #stdout 0.04s 9740KB
stdin
Standard input is empty
stdout
123456
$SETGLOBAL CCCC
BBBBBB
$SETGLOBAL TTTT