• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ReplaceList

New Here ,
Apr 26, 2011 Apr 26, 2011

Copy link to clipboard

Copied

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#")>

</cfloop>

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

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

TOPICS
Advanced techniques

Views

312

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 14, 2011 Jul 14, 2011

Copy link to clipboard

Copied

LATEST

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

e.g.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation