Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
The Expert Exam is now live online! Read about the specifics and what it took to bring it to life in the blog by our very own Elizabeth Bonnell!
SOLVED

Conditional RegEx

Highlighted
8 - Asteroid

Hello,

 

I am relatively a novice to RegEx and I'm close to my desired results but I have some data similar to the table below where I'm having an issue.

 

field1field1_desired
data 1 (abcd)abcd
data 2 (efg)efg
data 3 (afbc), data 4 (cgha)afbc, cgha
text 1text 1
text 2text 2
data 5 (ajdj)ajdj

 

Using this conditional statement below, the desired results are correct except for Row3:  data 3 (afbc), data 4 (cgha)

 

Formula:
IF(Contains([field1], "data")) then
REGEX_Replace([field1], ".*?\((.*)\).*", '$1') else [field1] endif

 

Result for Row3:

afbc), data 4 (cgha

Highlighted
16 - Nebula
16 - Nebula

I think a simple Regex replace:

 

REGEX_Replace([field1],"data \d+ \(([^)]+)\)","$1")

 

should work. This won't touch the non-data ones.

 

 

Highlighted
8 - Asteroid

@jdunkerley79 

 

Thanks so much, this worked perfectly.

Labels