community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

output specific parts of string

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.

 

Pulsar
Pulsar

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!

Nebula
Nebula

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