Alteryx Designer Desktop Discussions

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

Need help with regex formula

soncoku
9 - Comet

Hey everyone.

I need a formula (regex) that will find all the names that appear in this format.

 

Bob Alan Smith 17522691 AU

John Smith 13798229 UK

Jade Shaw 54654645345345 AR

Chriss Jaw 234322 AL

 

Any ideas?

9 REPLIES 9
TheOC
15 - Aurora
15 - Aurora

hi @soncoku 
I managed this with the formula:
^(.+?)\d

TheOC_1-1603283809819.png

This takes all the values before the first number in the field.

 

TheOC_0-1603283799690.png
I then split the result by space, but obviously this step is only necessary if you need to do so
Please find attached my workflow, hope this helped!

 


Bulien
StephaneP
Alteryx Alumni (Retired)

Hello @soncoku,

 

Here is a way of doing it.

StephaneP_0-1603283858499.png

StephaneP_1-1603283878931.png

 

 

Stéphane Portier
Sales Engineer
Alteryx
estherb47
15 - Aurora
15 - Aurora

Hi @soncoku 

 

Are you trying to pull the name part out, or find all strings with the pattern of text followed by a number followed by a two letter code in capital letters?

 


You can use a RegEx Match function inside a filter tool. If the pattern below represents the whole string, then those that match the pattern will come out on the T, and the rest on the F.

 

Is there more in each line in your data than what you've highlighted?

 

Cheers!

Esther

soncoku
9 - Comet

@estherb47 

@TheOC 

@StephaneP 

I apologize. I think I did a terrible job at explaining the problem.

So  I have a list that has about 20k names

Most of the names are in the format : 

FName + LName

Fname + Middle name + Lname

Fname + Lname + digits (about 8-10 digist or more)

 

Now in this list, I am only interested to find which names are of this format :
Bob Alan Smith 14679952 AL

or

Bob Smith 13479786 UK

So I ONLY want the names that have DIGITS after the name and 2 letter country code UK

Name digits Country Code = Bob Smith 14679753 UK

estherb47
15 - Aurora
15 - Aurora

@soncoku 

 

Thanks for the further explanation.

 

try this formula inside of a Filter tool: REGEX_Match([Name], "\D.+\d+\s\u{2}",0)

 

That will take strings that begin with a non-number, followed by a number, followed by a space, followed by a capital letter two letter code.

 


Let me know if that helps.

 

Cheers!

Esther

TheOC
15 - Aurora
15 - Aurora

@estherb47 
Very nice solution! I've tasked myself to learn more Regex and it still makes me want to pull my hair out haha!
I had put your solution in a workflow with the example data just to see if it worked/to learn from it, and seems to do the job perfectly!

 

@soncoku I've attached that below if you need


Bulien
estherb47
15 - Aurora
15 - Aurora

@TheOC that remains one of my favorite things about community, how we can learn from each other. I have become so much better at Alteryx by serving others here in the Designer discussions, and I've learned so much in solving together.

 

This is working out to be a fun team effort here!!

 

Cheers!


Esthter

StephaneP
Alteryx Alumni (Retired)

And to complete the trio here is the one using the RegEx tool. 😄
The tool showing how t extract data, the second just to check if it match.

 

I was looking for 3 starting surname/name and 1 was optionnal.

StephaneP_0-1603285931403.png

 

Let's leanr RegEx !! 🙂

 

Stéphane Portier
Sales Engineer
Alteryx
TheOC
15 - Aurora
15 - Aurora

@estherb47 
I completely agree, started Alteryx a matter of months ago, and addicted to the community!

Learning here is great and despite some people often beating me to solutions, (looking at you @atcodedog05  😉)  I think what's so good with Alteryx is there's always another way of doing things that people can learn from, so every solution is valuable.

Cheers!
Owen


Bulien
Labels