import re
regex = re.compile(r"(\*\S*)", flags=re.MULTILINE)
test_str = ("\"DEFINE QLOCAL *ALTDATE(2015-02-19) *ALTTIME(10.38.13) *CRDATE(2015-02-19) \n"
"*CRTIME(10.38.13) DISTL(NO) MAXDEPTH(999999999) MAXMSGL(32762) REPLACE DEFINE \n"
"QMODEL('SYSTEM.JMS.TEMPQ.MODEL') *ALTDATE(2015-02-19) *ALTTIME(10.38.14) *CRDATE(2015-02-19) *CRTIME(10.38.14) \n"
"DEFTYPE(TEMPDYN) DISTL(NO) MAXDEPTH(5000) MAXMSGL(104857600) *ALTDATE(2015-02-19)\".")
subst = ""
result = regex.sub(subst, test_str)
if result:
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html