
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 11:13 AM
Hello,
I have a long string that looks like this, i need to get the email address between < abc@example.com>
Can someone help me with this?
var a='abc, def<abc.def@example.com>; ghj, qwe <ghe.qwe@example.com>; bnm, jkl <bnm.jlk@example.com>;';
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 11:27 AM
Hi Nitesh,
So you need to get all email addresses between < and >
Sample script here:
var str = 'abc, def<abc.def@example.com>; ghj, qwe <ghe.qwe@example.com>; bnm, jkl <bnm.jlk@example.com>;';
var split1 = str.split(";");
var emailAddressArray = [];
for(var i=0;i<split1.length-1;i++){
var initialString = split1[i];
var emailAddress = initialString.substring(initialString.indexOf("<") + 1, initialString.indexOf(">"));
emailAddressArray.push(emailAddress.toString());
}
gs.print('Email Address Array is: ' + emailAddressArray);
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 11:27 AM
Hi Nitesh,
So you need to get all email addresses between < and >
Sample script here:
var str = 'abc, def<abc.def@example.com>; ghj, qwe <ghe.qwe@example.com>; bnm, jkl <bnm.jlk@example.com>;';
var split1 = str.split(";");
var emailAddressArray = [];
for(var i=0;i<split1.length-1;i++){
var initialString = split1[i];
var emailAddress = initialString.substring(initialString.indexOf("<") + 1, initialString.indexOf(">"));
emailAddressArray.push(emailAddress.toString());
}
gs.print('Email Address Array is: ' + emailAddressArray);
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 11:31 AM
Awesome, thanks!