import re
regex = re.compile(r"^(.*?)\bdefault\b", flags=re.MULTILINE)
test_str = ("../app/code/community/Company/Module/Block/Adminhtml/Location/Grid.php\n"
"../app/code/community/Company/Module/Block/Adminhtml/Location/Import.php\n"
"../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Form.php\n"
"../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Import.php\n"
"../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tabs.php\n"
"../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tab/Form.php\n"
"../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tab/Import.php\n"
"../app/code/community/Company/Module/controllers/IndexController.php\n"
"../app/code/community/Company/Module/controllers/LocationController.php\n"
"../app/design/adminhtml/default/default/layout/pmodule.xml\n"
"../app/design/frontend/default/default/layout/pmodule.xml\n"
"../app/design/frontend/default/default/template/company/module/gmap.phtml")
subst = "\\1rwd"
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