Hi,
Can anyone please let me know, how to find out the number of vowels in a string?
Thank you in advance
Discussion posts and replies are publicly visible
Use regular expressions function
community.appian.com/.../regular-expression-functions
regexallmatches( "[aeiouAEIOU]", "SIMPLE TEST")
a!localVariables( local!string: "APPIAN NAME", local!code: char(code(local!string)), local!tip: cleanwith(local!code,"aeiouAEIOU"), a!forEach( items: local!tip, expression: a!localVariables( concat("on " & fv!index & " index- " & local!tip[fv!index]) ) ))
a!localVariables( local!string: "APPIAN", local!vowels: {"A","E","I","O","U"}, length(wherecontains(local!vowels,char(code(local!string)))) )
Its not counting all the vowels, only first vowel is get counted
Great !
yeah - i also was thinking this is a clear-cut use case for cleanWith().
Genius !
As you can see, there are a bunch of possibilities here, but honestly I think most of these overcomplicate it:
a!localVariables( local!text: "Test phrase with vowels", len(cleanwith(local!text, "aeiouAEIOU")) )
As I try to not solve every problem using a loop, here my solution:
a!localVariables( local!text: "Television", local!vowels: { "a", "e", "i", "o", "u" }, count( union( intersection( code(lower(local!text)), code(local!vowels) ), tointeger({}) ) ) )