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

Alteryx Designer Desktop Discussions

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

output specific parts of string

janez_007
7 - Meteor

Hi Alteryx Community,

 

I need some support with a challenge - I have a string and I would like to output the part where numbers are present:

 

e.g. (string example    |    desired output):

 

C1.6.2-texttext    |    1.6.2

2.3-blabla    |     2.3

1-blablabla    |    1

1.5.6.7-texttexttext    |    1.5.6.7

 

There is always a "-" before the text starts, but the numbers can go several levels deep (1; 1.2; 1.2.3; 1.2.3.4, etc.) and there could be a "prefix", but not necessary. I think the examples above cover all my potential scenarios. I assume a clever RegEx can solve the issue, but I failed to produce something that would work.

 

Thank you.

 

2 REPLIES 2
Kenda
16 - Nebula
16 - Nebula

Hey @janez_007 !

 

RegEx is definitely what you want to use here. In a normal Formula tool, use this expression:

trim(REGEX_Replace([Field1], ".*\|\s(.*)", "$1"))

Basically, this is saying only keep what is after the space following the | symbol. Hope this helps!

danilang
19 - Altair
19 - Altair

Hi @janez_007 

 

If you use the following config in the RegEx tool, the numbers and the contained periods show up in RegExOut2

 

regexConfig.png

 

([[:alpha:]]*)(.*)(-.*)

 

The first group ([[:alpha:]]*) is zero or more characters.  the second is anything between the 1st and the "-" in the 3rd and the 3rd is "-" followed by anything else

 

Results

 

Results.png

 

Dan

 

 

Labels
Top Solution Authors