In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more 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