Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

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
21 - Polaris

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

 

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

binuacs_0-1674772328414.png

 

BS_THE_ANALYST
15 - Aurora
15 - Aurora

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

BS_THE_ANALYST_1-1674773544231.png

 

 

All the best,
BS

LinkedIN

Bulien
HomesickSurfer
12 - Quasar

Thank you @binuacs .  This works!!

Labels
Top Solution Authors