Skip to main content
supriyam0001
Participating Frequently
Oct 29, 2022 7:11 AM UTC
Solved

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

Hi,

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

Thank you in advance

peter.lewis
Employee
Oct 31, 2022 12:53 PM UTC

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

13 replies

Participating Frequently
Oct 29, 2022 7:51 AM UTC

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

New Participant
Dec 8, 2022 10:59 AM UTC

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

Known Participant
Oct 29, 2022 7:57 AM UTC

stefanhelzle0001
Brainy
Oct 29, 2022 1:14 PM UTC

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
Oct 31, 2022 12:53 PM UTC

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
Brainy
Oct 31, 2022 12:55 PM UTC

Genius !

shukurs0001
Known Participant
Dec 12, 2022 7:38 PM UTC

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

New Participant
Feb 24, 2024 2:44 PM UTC

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
Brainy
Feb 24, 2024 2:50 PM UTC

Use regular expressions function 

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

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

New Participant
Aug 16, 2026 5:59 AM UTC

For more interesting Appian Coding Questions , you check this site : https://appianverse.com/coding

rishikeshr4182
Inspiring
Aug 17, 2026 3:42 AM UTC

Hi ​@supriyam0001, Try this

if(
a!isNullOrEmpty(ri!text),
0,
length(regexallmatches("(?i)[aeiou]", ri!text))
)

 

Rishikesh