const regex = /#\d+[(=](\w+)\((.*?)\)[;A-Z]/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('#\\d+[(=](\\w+)\\((.*?)\\)[;A-Z]', 'gm')
const str = `#14(REPRESENTATION_RELATIONSHIP(\$,\$,#293,#291)REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION(#12)SHAPE_REPRESENTATION_RELATIONSHIP());
#35=MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION('',#180,888.125521);
#25=ADVANCED_BREP_SHAPE_REPRESENTATION('',(#29),#277);
#186=AXIS2_PLACEMENT_3D('',#270,#230,#231);`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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