Phil
Phil

Reputation: 63

Remove comma in coldfusion string

I am using,

#replaceList(oe.sql,";,&,<,>,`,',!,@,$,%,(,),=,+,{,},[,],\","")#

to remove unwanted characters from user input.

My problem is, that when I try all forbidden characters in the input-field replacelist removes every unwanted sign but leaves every comma there.

;,&,<,>,`,',!,@,$,%,(,),=,+,{,},[,],\ --> ,,,,,,,,,,,,,,,,,,,,

Does anyone know how to remove this? I tried:

,,, and ,[^,], in the "filter-string" and none of these worked...

#replace(#replaceList(oe.sql,";,&,<,>,`,',!,@,$,%,(,),=,+,{,},[,],\","")#,",","", "All")#

did also not work.

Upvotes: 2

Views: 3043

Answers (2)

Sergey Babrenok
Sergey Babrenok

Reputation: 186

Use REReplace or REReplaceNoCase functions to remove unwanted characters (specified as regular expression) from a string:

#REReplace(";,&,<,>,`,',!,@,$,%,(,),=,+,{,},[,],\", "[;&<>`'!@$%()=+{}[\]\\,""]*", "", "ALL")#

ReplaceList function is useful in case if you need to replace certain values from one list with corresponding values from another.

Upvotes: 2

Dan Bracuk
Dan Bracuk

Reputation: 20804

You can get rid of the empty list elements like this:

NewList = ArrayToList(ListToArray(OldList));

Upvotes: 2

Related Questions