Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

REGEX_Replace - Unable to Replace '+' Character in a String ...

Yanoflies
8 - Asteroid

[str] = "xyz+=/"

 

REGEX_Replace([str], "/", "%2F") = "xyz+=%2F"

REGEX_Replace([str], "=", "%2D") = "xyz+%2D/"

REGEX_Replace([str], "+", "%2B") = null


In the above, replace works fine unless you are trying to replace the character "+" -- there doesn't seem to be a way to escape the character either, why?

4 REPLIES 4
jdunkerley79
ACE Emeritus
ACE Emeritus

I would suggest using REPLACE rather than regex replace in these cases as you are not using regular expression functions.

Replace([str], "/", "%2F") = "xyz+=%2F"
Replace([str], "=", "%2D") = "xyz+%2D/"
Replace([str], "+", "%2B") = "xyz%2B=/"

To escape a plus in REGEX_Replace use \+:

REGEX_Replace([str], "\+", "%2B")
Yanoflies
8 - Asteroid

Thanks.

I wasn't using any REGEX in my example but I actually am in my model, it still wouldn't work with "\+" so I ended up using the normal REPLACE() in combination and that seems to work.

jdunkerley79
ACE Emeritus
ACE Emeritus

You can also use [+] if \+ doesn't work

 

Should work to escape + as well

Yanoflies
8 - Asteroid

Thank you!

Labels
Top Solution Authors