Free Trial

Alteryx Designer Desktop Discussions

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

Regex to handle variability in ID setting

hellyars
13 - Pulsar

 

I need one regex to rule them all.

 

\w{2}\d{3} works but it captures too much.  Using the first example, it captures both PE015 (the desired target) and LM250.  The challenge is that sometimes the ID is at the start of the line with a space, with a colon, or at the end in parentheses, etc.

 

 

RAW_TEXTID 
PE015 - LM2500 GAS DIGITAL FUEL CONTROLPE015 
GB003 - Twisted RudderGB003 
AASP WM018WM018 
GW055: SPEED LOGSGW055 
CJ061 TitaniumCJ061 
Equipment Upgrades (DY006)DY006 
3 REPLIES 3
DataNath
17 - Castor
17 - Castor

Does this do the trick?

 

Expression: (^\w{2}\d{3}|\w{2}\d{3}$|\(\w{2}\d{3}\))

 

Workbook attached.

 

DataNath_0-1651709631356.png

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

\b[a-zA-Z]{2}\d{3}\b

 

regex_replace([text],".*(\b[a-zA-Z]{2}\d{3}\b).*",'$1')

 

 try it out and let me know

 

 cheers

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Qiu
21 - Polaris
21 - Polaris

@hellyars 
I can not really be sure but at least it works on the date set you procided.

.*?([A-Z]{2}\d{3})\W*.*

0505-hellyars.PNG

Labels
Top Solution Authors