import reaa='''123456$SETGLOBAL AAAABBBBBB$SETGLOBAL TTTT'''text="CCCC"print(re.sub(r"(\$SETGLOBAL\s+)\w+", r"\1{}".format(text), aa, 1))
Standard input is empty
123456 $SETGLOBAL CCCC BBBBBB $SETGLOBAL TTTT
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!