1 Reply Latest reply on Jul 14, 2011 1:59 PM by insuractive


    Golden Pelican

      I have used ReplaceList() to replace values in one list with other values, but what I need is a REReplaceList() that would replace all the values in a list with a regex. Any ideas how I'd do this? The only thing I can think of is doing a loop. Here's the code to put in "hey" every three characters into every word in the list #mylist# using a loop.


      <cfloop list="#mylist#" index="x">

      <cfset mynewword = reReplaceNoCase(#x#, "(.{3})", "\1hey", "all")>

      <cfset NewList = ReplaceNoCase(#NewList#, "#x#", "#mynewword#")>



      But if ReReplaceList existed, couldn't I just do this?:


      <cfset mynewlist = REReplaceList("#list#", "(.{3})", "\1hey", "all")>

        • 1. Re: ReplaceList
          insuractive Level 3

          I would think that if you define your pattern to exclude commas and spaces you could accomplish the same thing using a pattern like:


          ([^, ]{3})


          that is - match every character that is not a comma or space in 3 character sets




          #ReReplace(mylist, "([^, ]{3})", "\1hey", "all")#