Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

I want to get text from a String

Tausifk
6 - Meteoroid

 Hi Team,

 

I have below text in different columns. I want to fetch the value from a Text mentioned below. I tried using Regex but not succesful.

Can someone help me with the below solutions.

 

1) Initiative I25250: Travelling Services = Result i want here is "I25250"

2) Feature F12302: Travelling Issues = Result i want here is "F12302"

3) S123456: Travelling Feedback = Result i want here is "S123456"

 

Regards,

Tausif.

5 REPLIES 5
Kenda
16 - Nebula
16 - Nebula

Hi @Tausifk 

 

My recommendation would be to use a normal Formula tool with the following expression:

REGEX_Replace([Field1], "(.*\s)?(.*)\:.*", "$2")

 

 

Hope this helps! 

Thableaus
17 - Castor
17 - Castor

Hi @Tausifk 

 

This might work:

 

REGEX_Replace([Field1], ".*([A-Z]\d+).*", "$1")

 

Cheers,

rafalolbert
ACE Emeritus
ACE Emeritus

Hi Tausifk,

 

This REGEX should do the trick: "([A-Z]{1}\d*):"

 

img.JPG

img2.JPG

 

I always use this page for testing: https://regex101.com/.

 

Hope this helps!

 

Thanks,

Rafal

 

#Excuse me, do you speak Alteryx?

Tausifk
6 - Meteoroid

Thanks for the reply.

 

Can you please explain me how the REG_EX function works.

 

I am new to Altereyx so not able to understand the way it is written.

 

Regards,

Tausif.

neilgallen
12 - Quasar

Regular Expressions are just pattern matching. You identify (often using operators instead of actual text) a pattern that you would like to look for, and then what you want to do once that pattern is found.

 

In the case of the suggested solutions:

 

from @Kenda 

REGEX_Replace([Field1], "(.*\s)?(.*)\:.*", "$2")

 Group everything before a space together. After that space, group everything until a ":" together. Since she's using "replace", then replace the ENTIRE pattern with whatever you find in the second group (between the space and the ":").

 

from @Thableaus 

 

REGEX_Replace([Field1], ".*([A-Z]\d+).*", "$1")

 

Look for one letter followed by a string of numbers, and then return that grouping.

 

from @rafalolbert

 

"([A-Z]{1}\d*):"

 

Look for exactly one letter, followed by a string of numbers, and return that grouping. The difference is it's being used in a parse setting which created a new field from the regex tool. A subtle difference between this one and the solution from @Thableaus is the \d+ vs \d*. In this case @Thableaus requires there to be a number (the plus sign meaning at least one, but could be many). The \d* says there could be zero digits.

 

Given your use case, I think the statements from @Kenda or @Thableaus are the best bet.

Labels