Skip to main content
Inspiring
October 20, 2012
Question

Replacenocase - Replacing multiple items in one go?

  • October 20, 2012
  • 2 replies
  • 1297 views

I've searched around and can't seem to find anything, but thought I'd post just incase somebody had an answer to this.

I have a string that I need to use replacenocase on to replace several fields, as an example

myoriginalstring="abc#first#-#second#"

What I want todo is look for the instance of #first# in the string (I know I need to double up on the # to ##) with a value of 99, and then also replace any instance of #second# with 88.

The question is, do I ahve to run two replacenocase statements, replacing one first, then taking the new string and running it again?

I have about 5 different things to search for in the string, and right now I have five statements.

Is there a better way so that it can be done in one statement?

Thanks

Mark

This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
October 21, 2012

ACS LLC wrote:

The question is, do I ahve to run two replacenocase statements, replacing one first, then taking the new string and running it again?

Yes.

Inspiring
October 20, 2012

Well, there's no nocase version of it, but there is a replaceList() function which'll go some way towards sorting your problem out.

http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6e17.html

I recommend having a scan through all the functions CFML has... don't try to memorise them all or all the minutiae of them, but at least eyeball them so you get an idea of what 's possible.  And the best way to search the docs is to get Google to do it for you.  If you searched on "site:help.adobe.com/en_US/ColdFusion/10.0/ replace" replaceList() is the fourth match...

--

Adam