Alteryx Designer Desktop Discussions

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

RegEx to to replace space with '/'

akshayhendre
7 - Meteor

Hello All,

 

I have a code where I am trying to replace the space with '/' using RegEx but not getting desired output.

I wrote the code in dynamic input tool,

IF [_CurrentField_] = 'Name'
THEN 'Type'
ELSE 'Week of ' + Regex_Replace(Replace([_CurrentField_],'_', ' '),'^\d+\s','')
ENDIF

Image 1 is before running the workflow and Image 2 is after running the workflow where I want the date separated by '/'.

Image:1Image:1

 

Image: 2Image: 2

 

Can anyone help me to do this.

 

Thank you

3 REPLIES 3
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @akshayhendre,

 

I've edited your formula slightly to introduce another Regex_Replace() function

 

IF [_CurrentField_] = 'Name'
THEN 'Type'
ELSE 'Week of ' + Regex_Replace(Regex_Replace(Replace([_CurrentField_],'_', ' '),'^\d+\s',''), '(\d)\s(\d)', '$1/$2')
ENDIF

 

Jonathan-Sherman_0-1589534051421.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

 

Hannah_Lissaman
11 - Bolide

Hi @akshayhendre 

 

Your expression was very close to working!

 

Try Regex_Replace(Replace([_CurrentField_], '_', '/'), '^\d+/', '')

 

I changed to add the / in the inner Replace function, then adjusted your Regex_Replace to account for this. 

akshayhendre
7 - Meteor

Thank you @Jonathan-Sherman and @Hannah_Lissaman, both the solutions worked for me 

Labels