indexOf doesn't match the exact string?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2018 04:08 AM
Hi team,
I have a requirement to get the exact string comparison results.
if my condition is like [ if (emailTo.indexOf("networkoperation@test.com") != -1) ]
it will also satisfy the conditions if the email To contains like the following("operation@test.com")
How to find the exact string matching?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2018 04:21 AM
use startsWith()
if (emailTo.startsWith("networkoperation@test.com"))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2018 04:29 AM
if the email TO contains "networkoperationteam@test.com" means the startsWith condition will match right?
Correct me if I was wrong

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2018 04:31 AM
i have updated the script
var emails='networkoperation@test.com';
if (emails.startsWith("operation@test.com"))
{
gs.print('hello');
}
else
{
gs.print('not hello');
}
if in variables i have define "networkoperation@test.com" and i tried to match with "operation@test.com" then it will go to the else condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2018 04:34 AM
I will test this and let you know.