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
Hi, Check the below code
a!localVariables( local!text: "Television", local!vowels: { "a", "e", "i", "o", "U" }, local!getVowels: a!forEach( items: char(code(local!text)), expression: if( contains(local!vowels, lower(fv!item)), fv!item, {} ) ), length(local!getVowels) )
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({}) ) ) )
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")) )
Genius !
yeah - i also was thinking this is a clear-cut use case for cleanWith().
Great !
Its not counting all the vowels, only first vowel is get counted
a!localVariables( local!string: "APPIAN", local!vowels: {"A","E","I","O","U"}, length(wherecontains(local!vowels,char(code(local!string)))) )
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]) ) ))