Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Apologies- One more REGEX help

jbh1128d1
10 - Fireball

 

Hello,

 

I had a key change in my r code and now my regex is not working.  I'm trying to parse out the below bold/italic text.  The bold/italic will always change (in case of the knots, it could be more or less numbers) but the rest will stay the same. 

 

I've tried "\w*\((\w*)\,.*\((.*)\)\).*(/w)" but that does not seem to work.

 

bs(rba_bucket, knots = c(3250, 40000), degree = 1)2

 

Thank you for the help.

3 REPLIES 3
MarqueeCrew
20 - Arcturus
20 - Arcturus

@jbh1128d1

 

output
rba_bucket, knots |3250, 40000|2

 

 

REGEX_Replace([Data], ".*?\((.*?)=.*\((.*?)\).*\)(\d+)", '$1|$2|$3')

skip everything until the FIRST ( character found:            .*?\(

group 1 is everything that comes next up to the first = sign:  (.*?)=

skip everything until the FIRST ( character found:           .*?\(

group 2 is everything the comes next up to the firs ) sign:  (.*?)\)

skip everything until the last ( character found:               .*\)

group 3 is all numbers that are left:                                        (\d+)

 

From here, you can parse the data if needed.

 

Cheers,

Mark

 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
MSalvage
11 - Bolide

@jbh1128d1,

 

This should do the trick:

 

bs\((.*)\,\s(.*) = c\((.*)\,\s(.*)\).*\)(\d)

 

not exactly sure how you wanted it all split out. knots is bold but in your sample you weren't pulling it so I just left it in.

If you don't want "knots" this will work:

 

bs\((.*)\,.*\((.*)\,\s(.*)\).*\)(\d)

 

Best,

MSalvage

jbh1128d1
10 - Fireball

Thank you MSalvage.  

 

In terms of "bs\((.*)\,.*\((.*)\,\s(.*)\).*\)(\d)", it seems to work on some not others.  For example, bs(veh_age, knots = c(7,18), degree = 1)1 works exactly how I'm intending it to use.  But for bs(rba_bucket, knots = c(3250), degree = 1)1 or bs(credit_tier_bucket, knots = c(399), degree = 1)1  Maybe it is because the there is only one knot for those?  

Labels
Top Solution Authors