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.

String Validation (starts with)

Derek10
Tera Expert

Greetings all,

I'm looking for some assistance on syntax for a series of start withs

IE if it startswith ABC, or XYZ or CAT.


I know it's a on change script for the variable, just not sure on how to match characters. (case insensitive)

Any thoughts?

1 ACCEPTED SOLUTION

drjohnchun
Tera Guru

Here's one way to do it using test():



if (/^(ABC|XYZ|CAT)/i.test(value)) {   /* process TRUE condition */   }   // starts with ABC or XYZ or CAT, ignore case



Hope this helps.



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


View solution in original post

5 REPLIES 5

Derek10
Tera Expert

Thank you all for your assistance, all of you have been helpful in this. I had to mark the most useful as correct as it directly correlated to my scenario. But I appreciate the other two and can reference them as well in future endeavors!.