Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

RegEx Parse Entire Digits from String

karenewilkins
7 - Meteor

After an incredible class at Inspire 2024 (with Albert Bellamy), I was sure I could figure out an issue I'm having with a RegEx expression. I was wrong. Maybe someone could assist.

 

I have a project where I'm trying to parse the digits from records in a flat file. I want the first set of digits (could range from 5 digits to 16), after the "0". However, I don't want to parse those that don't have a 3 character non-digit in the string.

 

For example (attached), I have the below records:

 

sample.PNG

I want to extract the highlighted digits, but not the "00000000" in record 3. As you can see there are three characters in the first 2 records after the digits I want ("FFM","ADJ") - possibly use that to identify the digits I want?

 

Basically I want the parsed records to look like this:

 

sample output.PNG

 

The expression I'm using is "^(0)(\d{4,16})\s\s+(.+)". It gets me what I want, except it's parsing the "00000000" into the first column of my parsed records.

 

Thoughts?

 

 

3 REPLIES 3
flying008
14 - Magnetar

Hi, @karenewilkins 

 

Match by :

 

 

^(0\d{4,16})(?=\s+[A-Z]).*

 

 

 

Replace to $1 :

 

 

^(0\d{4,16})(?=\s+[A-Z])

 

 

 

 

录制_2024_05_14_10_34_23_738.gif

 

录制_2024_05_14_10_38_11_217.gif

binuacs
20 - Arcturus

@karenewilkins Another regex

image.png

karenewilkins
7 - Meteor

@binuacs & @flying008  - thank you so much.

 

I opted for "^(0\d{4,16})(?=\s+[A-Z])(.*)$", as the three characters could be a combination of other letters other than FFM and ADJ.

 

This works perfectly!

Labels