const regex = /^(.*?)\bdefault\b/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^(.*?)\\bdefault\\b', 'gm')
const str = `../app/code/community/Company/Module/Block/Adminhtml/Location/Grid.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Import.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Form.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Import.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tabs.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tab/Form.php
../app/code/community/Company/Module/Block/Adminhtml/Location/Edit/Tab/Import.php
../app/code/community/Company/Module/controllers/IndexController.php
../app/code/community/Company/Module/controllers/LocationController.php
../app/design/adminhtml/default/default/layout/pmodule.xml
../app/design/frontend/default/default/layout/pmodule.xml
../app/design/frontend/default/default/template/company/module/gmap.phtml`;
const subst = `\1rwd`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', 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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions