Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Regex won't parse more than 1 digit before string condition

hamiltonfrye
5 - Atom

Hello all,

 

I'm really new to Alteryx and Regex, and I'm having trouble parsing a pack quantity out of a description field.  Here's my current expression:

 

.*(\d+)PK.*

 

Here's the expected result:                                 But here's the output I'm getting:

Description Field       Parsed Field                      Description Field       Parsed Field    

Beer 12PK                12                                       Beer 12PK                2

Stout 4PK IPA            4                                        Stout 4PK IPA           4

 

I thought the + sign after the /d was supposed to capture one or more digits, but it looks like regex just continues once it finds at least one digit before the string, and then stops counting.  How do I get it to capture any amount of digits before the "PK" abbreviation?

 

2 REPLIES 2
TylerNa
10 - Fireball

Try setting your RegEx tool to parse and use the following expression (\d+)PK

hamiltonfrye
5 - Atom

Well that was easy, I didn't realize regex defaulted to putting wildcards around whatever your expression is.

 

Do you know why it wasn't behaving the same the way I originally had it?

 

Either way thank you so much!!

Labels