Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Regex

CalDowd98
8 - Asteroid

Hi Community,

 

I have a string of address data where im trying to pull out the first number from it. EG 23 Caldowd98 Road, i'd like to pull out the 23, the first number.

 

Is there a Regex funtion out there that will allow me to do this ? Thank you !

13 REPLIES 13
T_Willins
14 - Magnetar
14 - Magnetar

Hi @CalDowd98,

 

This will work as long as there is a space following the first number set:

 

.*?(\d+?)\s+

 

bpatel
Alteryx
Alteryx

hi @CalDowd98 ,

 

The expression below would work too for parsing out your data.

 

..\s*(\d\d)

 

the \s* is an optional space expression.

 

bpatel_0-1573158212360.png

i hope this helps!

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @CalDowd98,

 

You could simply use (\d+) inside a regex tool. This would extract the first (and only the first) number in the string, in this case "23". No need to over complicate it unless we have to otherwise we're just increasing processing time and memory used, slowing the workflow down. image.png

 

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

CalDowd98
8 - Asteroid

Hi Jonathan,

 

Thanks for the help works great !

 

Just one last thing, if i have the street number 23a for example, how would i get the first letter as well if its stung together ?

 

thanks !

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @CalDowd98,

 

You could change it to (\w+) this would extract the first alpha numeric characters.

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached an updated workflow for you too.

 

Regards,

Jonathan

CalDowd98
8 - Asteroid

HI John,

 

Thanks for the help 🙂

 

This doesn't quite solve it unfortunately. There are times when i have a house name invloved which im looking to extract into a different column afterwards.

 

EG Callum House 23 Callum Drive, 25b Callum Drive

 

Im just looking to get the 23 and 25b, currently it will get Callum and then 25b

 

Any tips ?

 

thank you again !

Jonathan-Sherman
15 - Aurora
15 - Aurora

Could you attach a table of perhaps 5 records with columns of the data you're looking to extract from each?

CalDowd98
8 - Asteroid

Sure, see attached my attempts so far. They are the 3 at the end, where i try and get the house number after finding the flat/ flat number.

 

Hope that makes sense !

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi,

 

So is this what you're looking for?

 

image.png

 

If this solves your issue please mark as correct, if not let me know! I've attached my workbook for you to download if needed.

 

Regards,

Jonathan

Labels