ColdFusion replication will return a string

I am trying to clear submitted file names.

I use replacelist(filename,"',##,&, ",",,and,-")which should

  • delete 'and#
  • replace &withand
  • replace spaces with -.

When given "apost & pound#.JPG"instead of returning:

    "aposts-and-pound.jpg" 

replaceList returns:

    "apostandspound-.JPG"

I am using ColdFusion 10.

+5
source share
1 answer

This is not a reordering - it is related to how CF list processing works - empty elements are ignored / deleted.

Some of the List ~ string processing functions have an additional argument for changing this behavior (i.e., treat empty elements as an empty string), but the ReplaceList is not displayed.

, :

<cfset NewFilename = rereplace(Filename,"['##]","","all") />
<cfset NewFilename = replacelist(NewFilename,"&, ","and,-") />

replacelist( rereplace(filename,"['##]","","all") , "&, " , "and,-" )
+8

All Articles