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

Conditional RegEx

BonusCup
10 - Fireball

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

2 REPLIES 2
jdunkerley79
ACE Emeritus
ACE Emeritus

I think a simple Regex replace:

 

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

 

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

 

 

BonusCup
10 - Fireball

@jdunkerley79 

 

Thanks so much, this worked perfectly.

Labels