Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Reg Expression pattern

Anastasio_Theohari
8 - Asteroid

Hello guys,

 

i have a string and i would like to retrieve every digit character(including the '-' unitl the first char character..)

 

So in case of input,

 

811-1030 SOMETHING - WHATEVER TRASPORTATION & WHATEVER

512-0100 SOMETHING - WHATEVER (Direct)

448514 Whatever

179 Whatever 8,

 

i would like the output will be : 

 

811-1030

512-0100

448514

179

 

Any idea?

Thank you

4 REPLIES 4
Ladarthure
14 - Magnetar
14 - Magnetar

Hi @Anastasio_Theohari,

 

if you want to do it using regex you could use a regex like this one (.+\d)\s(.+)

 

But I would more likely advise you to use a text to columns tool with a space separator, it will split your column into 2 columns, and you only have to keep the first one. Performance wise it will be better and easier to maintain.

binuacs
21 - Polaris

@Anastasio_Theohari @Another way of doing this by the REGEX_Replace formula in the formula tool

 

REGEX_Replace([data], ‘(.+?)\s.*’, ‘$1’)

OllieClarke
16 - Nebula
16 - Nebula

edit: misread question, but couldn't delete ¯\_(ツ)_/¯

MarqueeCrew
20 - Arcturus
20 - Arcturus

@Anastasio_Theohari ,

 

personally if the first word is what you're after:

 

getword([text],0)

 

 is the expression that I'd recommend.

 

 Cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels
Top Solution Authors