Solved

Question about using rereplacenocase

Posted on 2002-06-12
4
133 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XML problem with Internet Explorer 7 30
Nginx CDN 12 114
Asp.net Hosting Plan security, reliable, stable 1 70
spamming  on Hosted svrs? 6 50
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now