const regex = /CallerID:\n([0-9\-\s\.]+)/ism;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('CallerID:\\n([0-9\\-\\s\\.]+)', 'ism')
const str = `Voice Mail Message: Double click on the attachment to play the voice mail file.
Date:
12/01/2014 01:28:36 PM
Number:
800-123-4567, JOHN SMITH
CallerID:
123-456-7890, JANE DOE
Destination:
Voice Mail
File Duration:
00:00:37
======================
Name : Jane Doe
Address : 123 Fake Street , Miami , Florida
Phone : 123-456-7890
Ye, my name is Jane Doe. I own the property at 123 Fake Street , Miami , Florida. You sent me a couple of postcards. Let me know if you're interested in making an offer. it's a single family home.3 bedrooms, 2 baths. Has a single efficiency in the back, that's an additional rental income.
Again, Jane Doe and that's 123 Fake Street and my phone number is 123-456-7890. Thanks !
`;
// 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