Solved

Question about using rereplacenocase

Posted on 2002-06-12
4
137 Views
Last Modified: 2013-12-24
Hi Everyone:

I have the following var ThisVar= foo_1_bar

I'd like to dynamically extract foo_ and _bar.
And store the new value (1) in a new var.

Using this <cfset ThisNewVar= rereplacenocase ThisVar,"foo_","","ALL")>

I am able to extract the foo_ regular expression.

I could not find a way to extract both regular expressions (foo and bar) and store the new value in the new var(ThisNewVar).

Any help would be appreciated

Thanks

Nickel    
0
Comment
Question by:nickel2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Expert Comment

by:anandkp
ID: 7074693
Hi there,

following is the ans - from what i could understand of ur Q's.

Create Dynamic variables ...

U could <CFSET ThisVar = "foo_#Val#_bar">

Now when u r in a loop - u will have the values of val being chanegd dynamically & so everytime ur Thisvar varible would be different.

then u could evaluate(ThisVar) to get new value each time in the loop.

let me know if this helps - or u need more clarification in this.

Regards
Anand
 
0
 

Author Comment

by:nickel2001
ID: 7076523
thanks for your help
0
 
LVL 2

Accepted Solution

by:
hammond_david earned 100 total points
ID: 7082025
I understood the question differently than the last person to comment.  What I thought you wanted to do was the following:

<cfset ThisNewVar = REReplaceNoCase(ThisVar,"foo_([^_]*)_bar","\1")>

This would set ThisNewVar to the string between "foo_" and "_bar", assuming that it does not contain and underscore character.  "\1" is a replacement expression referencing the first portion of the regular expression enclosed in parenthesis "[^_]*".

Hope that helps
- David
0
 

Author Comment

by:nickel2001
ID: 7083859
David:

I solved the problem with two expressions

<cfset ThisNewVar= rereplacenocase (ThisVar,"foo_","","ALL")>
<cfset ThisNewVar= rereplacenocase (ThisNewVar,"_bar","","ALL")>

Did not try out your idea yet.

Thanks for your help

Nickel
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question