Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Skip first match regex

alvaroez
5 - Atom

Hi,

 

I have a problem with this regex. I try to match the second numbers in the string including the next word. What I've tried is this:

 

\s([\d\/\.\%]*[\d]+)[\s]+([^\d\s\/\%]+)

But what I matched was 30 MEQ.

 

I want to match this:

PEDIALYTE 30 MEQ ORAL CEREZA 500 ML SOL 6638

 

Thank you for readme.

7 REPLIES 7
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @alvaroez,

 

It's a little difficult to adjust the regex from just one line of data, have you got a larger sample with the outputs you're looking for?

 

Kind regards,

Jonathan

apathetichell
19 - Altair

(\d+\sML) in regex parse tool. - and then just split off the ML with something like regex_replace([RegExOut1],"(\d+)(\sML)","$1") - although there are a TON of ways to isolate the numbers after.

Jonathan-Sherman
15 - Aurora
15 - Aurora

@apathetichell if you moved the capture group brackets to wrap just the \d+ you'd only be extracting the digits in parse mode and wouldn't need the more complex RegexReplace() function 😊

 

Doing (\d+)\sML in parse mode would do the same as both your functions, just thought i'd point it out!

 

Kind regards,

Jonathan

apathetichell
19 - Altair

@Jonathan-Shermanthanks! I know it should do that - but for some reason (ie my own sloppy REGEX) - I've had situations where it's easier to just capture the junk and then remove it later.

alvaroez
5 - Atom

Hi @

 

PEDIALYTE 30 MEQ ORAL CEREZA 500 ML SOL   6638
PEDIALYTE 45 MEQ ORAL FRESA 500 ML SOL   6690
PEDIALYTE 45 MEQ ORAL MANZANA 500 ML SOL   6713
PEDIALYTE 60 MEQ ORAL UVA 500 ML SOL   6775
PEDIALYTE ORAL COCO 500 ML SOL   0127
 
 
PEDIALYTE SR 60 COCO 500 ML 1366
PEDIALYTE SR 60 FRESA 500 ML 1373
PEDIALYTE SR 60 ORAL MANZANA 500 ML SOL   4740

 

This is a larger sample of data I want to parse an obtain the second digits and the next word. I hope you can help me.

 

Thank you for answering.

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @alvaroez,

 

You could use the following regex expression to solve it:

 

(\d+\sML)

 

Jonathan-Sherman_1-1621980789642.png

 

I've attached my workflow for you to download if needed!

 

Kind regards,

Jonathan

apathetichell
19 - Altair

@Jonathan-Sherman I'm psychic!

 

@alvaroezFYI - my regex above -  extracted that entire string and dumped the ML part in a second formula - so you can just remove that part...

Labels
Top Solution Authors