Alteryx Designer Discussions

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

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

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?

16 - Nebula
16 - Nebula

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")
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.

16 - Nebula
16 - Nebula

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

 

Should work to escape + as well

8 - Asteroid

Thank you!

Labels