Start Free Trial

Alteryx Designer Desktop Discussions

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

Regex replace to return match

Nchto
6 - Meteoroid

Hello,

I am trying to only use formula tool for this. Basically i want to get an exact match from my regex expression.

input ex: SDF-TECES33V12-5Y

from this i would like to extract the numbers between S and V (might sometimes be 3 or 4 numbers)

so from this, for example, i would like to get only the number 33.

 

i tried using this:

REGEX_Replace([Name], "(?=S)(.*?)(?<=V)","$1")

 

thanks in advance for any help

6 REPLIES 6
AkimasaKajitani
17 - Castor
17 - Castor

Does this work?

 

I'm using \d+ because you want to get the numbers between S and V.

 

REGEX_Replace([Field1], ".*S(\d+)V.*", "$1")

 

Nchto
6 - Meteoroid

Worked like a charm, many thanks!

By any chance could you help me getting the last two charcters? its always a number followed by Y

 

Tried using:

REGEX_Replace([Name], "\+dY","$1")

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

".*-(\d+)Y",'$1'

 

 gets you 1 or more digits between - and Y

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
apathetichell
20 - Arcturus

Hi,

 

Regex might not be the easiest way to get those characters. If it's always the last two digits you could use a left(right([name],3),2) in lieu of using a Regex. If you need to test for if the last character is a Y you can add an if right([name],1)=Y or a Trim.

Nchto
6 - Meteoroid

You are right, that is much simpler

Nchto
6 - Meteoroid

got it working, thanks!

Labels
Top Solution Authors