?
Solved

Can I use a wildcard in this Reg Expression?

Posted on 2011-10-10
5
Medium Priority
?
284 Views
Last Modified: 2012-05-12

I have this, it's getting an id out of a file in a directory.

  <cfset theNum=ReReplaceNoCase(cs_uri_stem,".+/Floorplan(\d+).+","\1") >

But I want to know if I can just use a wildcard/asterisk in case there is some other chars in front of the word Floorplan...

Does this work? How would I do it?

  <cfset theNum=ReReplaceNoCase(cs_uri_stem,".+/*Floorplan(\d+).+","\1") >
0
Comment
Question by:monosyth
  • 4
5 Comments
 

Author Comment

by:monosyth
ID: 36944842

Real life example is:

files it could be looking at might be:

images/ashtonpark_code2___Floorplan5586.jpg
images/ashtonpark_code2__234_Floorplan5586.jpg
images/Floorplan5586.jpg

I'm just trying to get the ID before the jpg and after the word Floorplan. Thanks!!
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 2000 total points
ID: 36944858
Close - try this:
  <cfset theNum=ReReplaceNoCase(cs_uri_stem,".+/[^/]*Floorplan(\d+).+","\1") > 
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 36944879
Perhaps simpler:
  <cfset theNum=ReReplaceNoCase(cs_uri_stem,"Floorplan(\d+)\D","\1") > 
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 36944887
Sorry - that last suggestion is not suitable for a replace. My first suggestion should be fine I think.
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 36944903
Is there any chance the image could be more than one directory deep? If so, it would help to know whether the value in cs_uri_stem might contain anything before the directory name that you don't want replaced. If not, then this would allow anything at all before "Floorplan":
  <cfset theNum=ReReplaceNoCase(cs_uri_stem,".*Floorplan(\d+).+","\1") > 
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

831 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