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
Solved! Go to Solution.
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
Any updates on this @hellyars ?
@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?
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
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.
and the output:
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
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
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
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