Skip to main content
supriyam0001
October 29, 2022
Solved

How to find out the number of vowels in a string in Appian ?

  • October 29, 2022
  • 11 replies
  • 0 views

Hi,

Can anyone please let me know, how to find out the number of vowels in a string?

Thank you in advance

Best answer by peter.lewis

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"))
)

11 replies

October 29, 2022

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)
)

December 8, 2022

Its not counting all the vowels, only first vowel is get counted

October 29, 2022

stefanhelzle0001
October 29, 2022

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({})
    )
  )
)

peter.lewis
Employee
October 31, 2022

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"))
)

stefanhelzle0001
October 31, 2022

Genius !

shukurs0001
December 12, 2022

a!localVariables(
  local!string: "APPIAN",
  local!vowels: {"A","E","I","O","U"},
  length(wherecontains(local!vowels,char(code(local!string))))
)

February 24, 2024

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])
)
)
)

davidj137213
February 24, 2024

Use regular expressions function 

community.appian.com/.../regular-expression-functions

regexallmatches(
"[aeiouAEIOU]",
"SIMPLE TEST")