Alteryx Designer Desktop Discussions

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

Regex to replace serial number in string

piyush
6 - Meteoroid

Hi All,

 

i have a string in following format

 

( 1 ) GN49B ( 2 ) SI25B ( 3 ) SN45B ( 4 ) SN55B ( 5 ) SN60B ( 6 ) SR20B ( 7 ) SR25B ( 8 ) SR35B ( 9 ) SR4

 

i need the output in following way

GN49B,SI25B,SN45B,SN55B, SN60B, SR20B,SR25B,SR35B,SR4

 

can somebody please help me to write a regex to achieve this i am new to regex.

5 REPLIES 5
estherb47
15 - Aurora
15 - Aurora

Hi @piyush 

Try these 2 formulas in a formula tool. The first gets rid of the opening (1) and the next replaces the series numbers with commas.

image.png

 

Let me know if that helps!!

 

Cheers,

Esther

piyush
6 - Meteoroid

Hi @estherb47 ,

 

This works fine except one condition i have some value as below

( 1 ) SSFV ( 2 )

 

the output is coming like this after the formula

SSFV ( 2 )

 

its should come like below so that i can break it using text as column using ","

SSFV,

estherb47
15 - Aurora
15 - Aurora

Hi @piyush 

 

You can try again, this time removing the \s (which represents spaces) from both sides. PErhaps that one instance doesn't have a space.

 

Let me know if that helps

 

Cheers!

Esther

benakesh
12 - Quasar

Hi @piyush ,

This site is good for  testing  regex before using it in Alteryx   :   https://regexr.com/4jf2b

caschecter
6 - Meteoroid
Piyush, Here is a thought. Use a data cleanse tool to get rid of all white space. Your data would look like this. (1)GN49B(2)SI25B(3)SN45B(4)SN55B(5)SN60B(6)SR20B(7)SR25B(8)SR35B(9)SR4 Then use a regex tool to do a replace of \(\d*\) with a comma. Clean up your first comma and you should have your desired output.
Labels