Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reg Expression in CF 2

Status
Not open for further replies.

toyt78

Technical User
Apr 5, 2005
125
US
I want to put in a reg expression to condense my conditions below. Instead of having this:
Code:
<cfif #cgi.PATH_INFO# CONTAINS "mydirectory/dirOne/pagehere.cfm">
&gt; <a href="[URL unfurl="true"]http://www.sun.com/">Info</a>[/URL]
</cfif>
<cfif #cgi.PATH_INFO# CONTAINS "mydirectory/dirOne/anotherOne.cfm">
&gt; <a href="[URL unfurl="true"]http://www.sun.com/">Info</a>[/URL]
</cfif>
<cfif #cgi.PATH_INFO# CONTAINS "mydirectory/dirOne/next.cfm">
&gt; <a href="[URL unfurl="true"]http://www.sun.com/">Info</a>[/URL]
</cfif>

I can make a reg expression but it not working:
Code:
<cfif #cgi.PATH_INFO# CONTAINS "mydirectory/dirOne/*.cfm">
&gt; <a href="[URL unfurl="true"]http://www.sun.com/">Info</a>[/URL]
</cfif>


Please advise.
 
<cfset x = "mydirectory/dirOne/">
<cfif findNoCase("mydirectory/dirOne/",x)>
yep
<cfelse>
nope
</cfif>

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Since you are looking for the .cfm files, try something like this

<cfif ReFindNoCase("(mydirectory/dirOne/){1}", #cgi.path_info#, 1) AND ReFindNoCase("(.cfm){1}",#cgi.path_info#, 1)>
&gt; <a href="<cfelse>
not found!!!!.....
</cfif>

this will look for the directory mydirectory/dirOne/ and look for .cfm extension. there may be a better way to write this as well.
hope it helps...

 
that was paraphrased mr smarty pants, if you're going to hold a grudge for showing you up earlier you could at least post a solution.

what he said was if i'm in ANY cfm page in mydirectory/dirOne then make the hyperlink go to sun.com

since this script will only run in .cfm pages its moot to include the "*.cfm"

<cfif findNoCase("mydirectory/dirOne/",cgi.PATH_INFO>
&gt; <a href="</cfif>


We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Thanks it works great.

I am trying to figure out what it is doing here:
<cfif ReFindNoCase("(mydirectory/dirOne/){1}", #cgi.path_info#, 1) ...

Please explain especially the {1} part.

 
{x} match must occur exactly x times

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
here is a good tutorial on regex


We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
as he said,
<cfif ReFindNoCase("(mydirectory/dirOne/){1}", #cgi.path_info#, 1)

looks for the #cgi.path_info# string and tries to find {X} exact occurence of whatever is placed within "()"

hope it helps...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top