dojo script to find the substring
Hi All,
Can someone help me on how to find whether a given string contains a specific sub-string.
here is my scenario,
I have written a Script based condition where I`m reading the value of an attribute(Multi select). here when i select multiple values I`m getting a string with comma separated values but i want to know whether the user selected the option which I`m interested in.
Thanks
Surender
2 answers
I suppose you have a JavaScript String object, not necessarily a Dojo String object. In this case, either the indexOf() or the search() function should work for you.
http://www.w3schools.com/jsref/jsref_indexof.asp
http://www.w3schools.com/jsref/jsref_search.asp
Another approach is to split the string using comma as the separator. Then you can check whether any item in the resulting array is a match.
http://www.w3schools.com/jsref/jsref_split.asp
http://www.w3schools.com/jsref/jsref_indexof.asp
http://www.w3schools.com/jsref/jsref_search.asp
Another approach is to split the string using comma as the separator. Then you can check whether any item in the resulting array is a match.
http://www.w3schools.com/jsref/jsref_split.asp