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

Alteryx Designer Desktop Discussions

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

Regex: Data extraction from string

aravind_sk
8 - Asteroid

I'm trying to extract text and numeric patterns from a string. The strings are in the format of Account names, numbers, and some numbers.

 

1. Account Name 1   123456 10.256

2. Account & Na@me                      2789 11\\456

3. Ac_NT N123ame                                                             351462 12/453

 

The problem I’m facing is that the account name can have numbers within it, alpha/special characters/spaces within it.

 

When I write a pattern to extract the name, it greedily parses the spaces after the name and the account numbers after it. The only pattern I distinctly see in the data is that there is at least 3 spaces after the account name and before the account number.

 

So a pattern that catches everything before 3 spaces and then 3 or more digits after the spaces is what I’m looking for.

 

Would be great if someone can take a shot at this!

 

3 REPLIES 3
neilgallen
12 - Quasar
You could try

(\S+)(?:\s{3})(\d{3,})

Where \S is non-whitespace.
danilang
19 - Altair
19 - Altair

Hi @aravind_sk 

 

Try this one

 

(.*?)\s{3,}(\d{3,})\s+(.*)

 

(.*?)  extracts all non-greedy

\s{3,} 3 or more spaces

(\d{3,}) 3 or more digits

\s+ 1 or more spaces

(.*) rest of the line

 

giving this

 

Results.png

 

Dan

aravind_sk
8 - Asteroid

Thanks Dan! This one worked. I'll have to learn more of non-greediness :)

Labels