?
Solved

Question about using rereplacenocase

Posted on 2002-06-12
4
Medium Priority
?
139 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 400 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

771 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