/t5/coldfusion-discussions/udf-help/td-p/527432May 25, 2007
May 25, 2007
Copy link to clipboard
Copied
I am trying to write a UDF for replacing some characters from
my string. I am using replace list but somehow its just replacing
only first character but not the others in the list
Here is what I am trying to do
<cfscript>
function Rep(theString){
var remove_char_list = "&, |, \, >, <, :";
var replace_char_list = "and, ' ''';
return ReplaceList(theString, remove_char_list,
replace_char_list);
}
</cfscript>
basically & to be removed and (XML), and all other with
empty strings, with this it just replace all occurences of &
whereas others are not being replaced
/t5/coldfusion-discussions/udf-help/m-p/527433#M48219May 25, 2007
May 25, 2007
Copy link to clipboard
Copied
My main intent is to get rid of all the replaces that I was
using before and just ReplaceList because most of the characters
are to be replaced with empty string and only & with and
Now that I've read your reply, it seems like a better match
would be to do 2 replaces - 1st replace swaps out the ampersand
(&), 2nd replace uses regular expressions to remove everything
else