I have a string that may contain an apostrophe (') or an ampersand (&). I need to find if either one or both exists. If they do, then replace them with '' and/or '&
trim(Pos_Query_Super.replace(/'/g,"''"))
Can I add an and/or condition to the above and simply replace it using javascript? This development is in an process flow IDE were we can use JS expressions.
Yes, you can use a function to return the replacement based on the match
trim(Pos_Query_Super.replace(/'|&/g,function(match){
return {
'\'':'\''',
'&':'\'&'
}[match]
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With