6/17/21: We have completed maintenance for the Search functionality on the Community. If you are seeing any issues, please try to clear your cache first. If the issue persists please email Community@alteryx.com

Alteryx Designer Discussions

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

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

hellyars
12 - Quasar

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
aruiz-itp
11 - Bolide

Hi @hellyars 

 

Here an example

 

I hope it helps

AngelosPachis
15 - Aurora

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
15 - Aurora

Any updates on this @hellyars ?

hellyars
12 - Quasar

@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
19 - Altair
19 - Altair

@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 reboot. Order shall return.
Please Subscribe to my youTube channel.
AngelosPachis
15 - Aurora

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
19 - Altair
19 - Altair

@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 reboot. Order shall return.
Please Subscribe to my youTube channel.
AngelosPachis
15 - Aurora

@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
19 - Altair
19 - Altair

@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 reboot. Order shall return.
Please Subscribe to my youTube channel.
Labels