Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Remove all vowels from a string unless it is the first letter of a word.

hellyars
13 - Pulsar

I want to remove all vowels from a string of words :  a, e, i, o, u, y.  UNLESS its the first letter of a word.

 

Example:

 

Ground Control = Grnd Cntrl

Universal Control = Unvrsl Cntl

12 REPLIES 12
randreag
11 - Bolide

Hi @hellyars 

 

Here an example

 

I hope it helps

AngelosPachis
16 - Nebula

Hi @hellyars ,

 

You can use a RegEx replace function to achieve that. Just make sure that you add the 0 at the end to make it case sensitive

 

AngelosPachis_0-1611960033988.png

 

AngelosPachis
16 - Nebula

Any updates on this @hellyars ?

hellyars
13 - Pulsar

@AngelosPachis  Oh sorry, I got caught up trying to figure out Alteryx's reporting systems.  It is so ...Windows.  

 

Anyways, this works great.  But, I discovered one flaw in my approach.  I need to ignore this in the event the vowel is the first letter of a word.  Can this be modified?

MarqueeCrew
20 - Arcturus
20 - Arcturus

@hellyars ,

 

This FORMULA will eliminate non-1st letter Vowels.

 

REGEX_Replace([Field1], "\B[aeiouAEIOU]", '')

 

\B = non-word boundary (meaning, it isn't the first letter of a word).

[] = set of letters (lower or uppercase vowels)

 

Cheers,


Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
AngelosPachis
16 - Nebula

Yes you can. I've broken down each string to individual words and then used a formula tool to check if the first letter of each word is lowercase. If it's a lowercase, then leave it untouched, else remove all vowel characters.

 

AngelosPachis_1-1612045161538.png

 

and the output:

 

AngelosPachis_2-1612045171398.png

 

Edit : Tested that and realised it's not working as I thought it would. Thankfully @MarqueeCrew stepped in to save the day

 

Let me know if that worked for you.

 

Cheers,

 

Angelos

 

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

@AngelosPachis ,

 

 thanks for that mention! it definitely made me smile. I forgot where I first used word boundaries, but they definitely help. 

\b is worth learning. 

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
AngelosPachis
16 - Nebula

@MarqueeCrew 

 

Definitely that's one to learn and something I wasn't aware it was even a thing. Is there a difference between a capitalized B or a lowercase one. So is \b and \B treated the same in RegEx?

 

Thanks for that hint, learned something new

 

Cheers,


Angelos

MarqueeCrew
20 - Arcturus
20 - Arcturus

@AngelosPachis ,

 

uppercase is the opposite(\d is a digit and \D is NOT a digit)

\b is a word boundary. 
\B is NOT a word boundary

 

 my expression looks for a vowel that isn't preceded by a boundary.  If you used a space instead of the boundary, the first word wouldn't work. The boundary makes it simple. 

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels