const regex = /(\d+\.)+[\s\S]+?(?=(\d+\.)+|$)/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\d+\\.)+[\\s\\S]+?(?=(\\d+\\.)+|$)', '')
const str = `56.8. Liaise with the incumbent Service Provider to enable the full completion of the mobilisation period;
56.9. Produce and implement a communications plan , to be agreed with the Client, including the frequency, responsibility for and nature of communication with the Client and end users of the service;
56.10. Produce a mobilisation report for each Affected Property to encompass programmes that will fulfil all the Client’s obligations to landlords and other tenants. The format of reports and programmes shall be in accordance with the Client’s requirements. Particular attention shall be paid to establishing the operating requirements of the occupiers in drawing up these programmes for agreement with the Client;`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// 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