Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

REGEX to find Acronym, that may OR may not be there

hellyars
13 - Pulsar

Hi,

 

I have Name filed.   SOME names have acronyms associated with them.  The are set off by opening and closing parentheses ().  I want to split the field into 2 new fields, one for Name and one for Acronym.  

 

Example:  

EAT MORE TACOS (EMT)
EAT MORE TACOS

 

My REGEX is set to (^.*)\s(\([A-Z].*\)).  It works if the acronym is present, but it does not work if the acronym is not present.  

 

How do I make this work?

 

Thanks,

2 REPLIES 2
Thableaus
17 - Castor
17 - Castor

Hi @hellyars 

 

Try this:

 

(.*)\s(\([^)]+\))?

 

Parse mode Regex.


Cheers,

Claje
14 - Magnetar

Hi,


Try the following RegEx:

(^[^\(]*)\s(\([A-Z].*\))*

 

The two changes I made are as follows:

 

I changed your "any character" search to "any character other than an open parentheses" with [^\(]* instead of .*

 

I made your second argument (the one looking for anything in parentheses) optional with a * at the end.

Labels