Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

indexOf not working as expected?

gokulraj
Giga Expert

How to compare the string with exact match?

myString = "networkgroup@abc.com";

"network@abc.com" also satifying this condtion

Is there a way to find the exact string insted of indexOF()

16 REPLIES 16

That's for example I have shared the below is like i want

Comment = 'EVM00238-to1' not found/n 

mystring = EVM00238

if(Comment.indexOF(mystring)>-1)

this condition is satifying right now but I dont't want to do that, instead I want to match the exact string

I am not comparing eamil id for exaMPLE i HAVE shared that,

Comment = 'EVOOTBM-T05' is not exist;

myString = EVOOTBM;

if(Comment.toString.indexOF(myString)>1)

Now this should not satify but is is matching,

That's why I want a exact string matching condition

 

Do you only want to compare the value inside the ''?

yes you are right

How about this one: 

comments = 'EVMTMW-WOZ' item not found/n 'TMAQW-WOZ' does not exist

There are two of them with ''. Do you need both of them or just the first instance?