?
Solved

Question about using rereplacenocase

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
What You Need to Know when Searching for a Webhost Provider
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

850 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