It's all about the answers!

Ask a question

dojo script to find the substring


Surender Biyyala (403448) | asked Aug 06 '14, 1:07 p.m.
 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



permanent link
Tim Mok (6.6k38) | answered Aug 06 '14, 1:18 p.m.
JAZZ DEVELOPER
You should refer to the Dojo documentation: http://dojotoolkit.org/reference-guide/1.10/dojo/string.html#dojo-string

permanent link
Donald Nong (14.5k414) | answered Aug 07 '14, 12:11 a.m.
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

Your answer


Register or to post your answer.