Alteryx Designer Desktop Discussions

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

Replace nth occurrence of value in a string

HomesickSurfer
12 - Quasar

Hello

 

Anyone here know why my Alteryx formula expression isn't working?

Using the following, I intend to replace the 10th semicolon (;) in my strings with a tilde (~).

 

 

Replace([F15], "^(?:(?:[^;]*;){9}[^;]*);", "~")

 

 

Sample strings:
532.00;515;S;N;US80687P1066;20221027;20221031;2;UNT;51.49;Y; ;.15;XPAR;
533.00;515;S;N;US80687P1066;20221027;20221031;23;UNT;592.17;Y; ;1.78;XPAR;

3 REPLIES 3
binuacs
20 - Arcturus

@HomesickSurfer I think you need to use the Regex_Replace() function

 

REGEX_Replace([Sample strings:], '(^(?:(?:[^;]*;){9}[^;]*));', '$1~')

binuacs_0-1674772328414.png

 

BS_THE_ANALYST
14 - Magnetar

Thank you @binuacs for your logic. I learned alot from your solution. 👏

BS_THE_ANALYST_1-1674773544231.png

 

 

HomesickSurfer
12 - Quasar

Thank you @binuacs .  This works!!

Labels