Replace ampersand by html safe code problem
I have a simple calculation field, which aims to replace all special characters in a string.
This works :
"Chip & Dale".replace(/</g,"<");
"Chip & Dale".replace(/>/g,">");
"Chip & Dale".replace(/\'/g,"'");
"Chip & Dale".replace(/"/g,""");
but it doesn't work for
"Chip & Dale".replace(/&/g,"&");
=> No matter what I do, Podio refuses to transform "&" into "&" in the end result (it DOES however show & in the calculation preview)
Does Podio overrule this somehow? Anybody has an idea on how to force this?
-
Hi Mike,
first: It also doesn't work for the 4 others. If you replace <>'" by their entity they will be displayed as <>"' in calculation fields.
What you need is a zero-white-space before the semicolon.
You can either copy a zero-white-space to your clipboard (some websites offer that, just seach for it) and paste it before the semicolon or after the & - or you use an encoded UTF:"Chip & Dale".replace(/&/g,"&\u200B;")
In Globiflow you can use the Unicode as HTML encoded ​ to update e.g a multiline text field (but it works only after the &)
str_replace("&","&​amp;","Chip & Dale")
Rainer
Please sign in to leave a comment.
Comments
1 comment