Hi all,
I am looking for SAIL functions or logic I can use to find any of multiple characters within a string variable.
I have three variables as follows -
a!localVariables(
local!userInput: "Sample user input",local!charactersOfInterest: {"+", "$", "£", "€", "%"},local!isFoundCharacterOfInterest: -TRUE if any of the characters in local!charactersOfInterest are found in local!userInput, otherwise FALSE.-.
.
Any ideas how search local!userInput for any of the characters in local!charactersOfInterest and return true if any of the characters are found, otherwise return false?
Thanks
Discussion posts and replies are publicly visible
Basically for something like this, you can just loop over the set of characters of interest and use a function like "search" to search the original user input string for the current item - that would produce a list of booleans, which you can wrap in an or() statement to return true when any are true.
a!localVariables( local!userInput: "Sample user in+put", local!charactersOfInterest: {"+", "$", "£", "€", "%"}, local!isFoundCharacterOfInterest: or( a!forEach( local!charactersOfInterest, search(fv!item, local!userInput) > 0 ) ), local!isFoundCharacterOfInterest )
a!localVariables( local!userInput: "Sample user input", local!charactersOfInterest: {"+", "$", "£", "€", "%"}, any(find(_, local!userInput), local!charactersOfInterest) )
Yeah there's a top of options here (and both the ones above are good). Just to add one more possibility - my preference is to use the cleanwith() function because it doesn't require looping:
not( isnull( cleanwith( "tehsajksdhfalskdjfha $ 23ui34kjasdnf ", "+$£€%" ) ) )