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.

Handling forward slash in text

Brian Lancaster
Kilo Patron

I have an if statement where if (report == "string" || report == "string with forward slash in the middle of it).   If the first item is selected with just a string it evaluates correctly but the one with the forward slash in the string fails.   How do I handle this?

4 REPLIES 4

Jace Benson
Mega Sage

When you are messing with \ you will need to use two because it is the escape character.   This however is the backslash.



Try something like this;


//If you value is "String\Test"


if(report == "String\\Test"){


    //matches against String\Test


}



If I have this all wrong, post your actual if statement and the value you're trying to match.


Its a forward slash "string/test".   Adding two "sting//test" did not work.


You should not have to escape forward slashes but try matching against, "string\/test".


That did not work either