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

Replacenocase - Replacing multiple items in one go?

Enthusiast ,
Oct 20, 2012 Oct 20, 2012

Copy link to clipboard

Copied

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

TOPICS
Advanced techniques

Views

1.2K

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
LEGEND ,
Oct 20, 2012 Oct 20, 2012

Copy link to clipboard

Copied

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

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
Community Expert ,
Oct 21, 2012 Oct 21, 2012

Copy link to clipboard

Copied

LATEST

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.

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