I have a block of text containing a mix of emails, phone numbers, and URLs that I need to extract individually.
I attempted to use a substring method in JavaScript to achieve this, but I seem to be encountering some challenges.
Below is a snippet of the data I am working with:
*Email:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="31585f575e715053521f525e5c">[email protected]</a>
Url: www.example.com
Tel: +123-456-789
Email:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="523b3c343d123330317c313d3f">[email protected]</a>
Url: www.example.com
Tel: +123-456-789
Email:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="422b2c242d022320216c212d2f">[email protected]</a>
Url: www.example.com
Tel: +123-456-789
Email:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e881868e87a8898a8bc68b8785">[email protected]</a>
Url: www.example.com
Tel: +123-456-789*
I am looking for assistance in extracting this data using JavaScript.
var myEmails = [];
var data = myString.substr((myString.indexOf("Email:")+1),(myString.indexOf('Url:')-2));
for(let i=0;i<600;i++){
var extracted = myString.substr((myString.indexOf(data)+1),(myString.indexOf('Url:')-2));
console.log(extracted);
}