How to find a substring in a given string ?
-
I tried to use this https://stackoverflow.com/questions/1789945/how-to-check-whether-a-string-contains-a-substring-in-javascript
but when i enter the code in the javascript function in BAS, it always gives me error.
What is the correct way to use javascript functions with BAS variables ?
I used this code but it don't work :var string = [[SAVED_ATTRIBUTE]] , substring = 'something_to_search_for'; return string.indexOf(substring);
It will return -1 if string is not found but this method don't work, Is there any fix for this or other method to make it work? Please help @administrators
Thank you
-
You can use "regular expressions". Check if the string matches regexp
If it match it return TRUE else FALSE.
-
@niceusername Use "Custom" action with param
var string = "something_to_search_for_1" , substring = 'something_to_search_for'; [[INDEX]] = string.indexOf(substring);
Like this 0_1501254262342_contains.xml
You can also achieve this with visual constructor
-
Awesome thank you!