Definitely not perfect, but it does the trick
<cfset string = "http://www.mydomain.com/missingdirectory/dfgfdgf/index.cfm"
/>
<cfset result = reFindNoCase( "[a-z]/{1,1}.*$", string, 1, true ) />
<cfdump var="#result#">
<cfdump var="#mid( string, result.pos[ 1 ] + 1, result.len[ 1 ] )#">
--
Taco Fleur
Senior Web Systems Engineer
http://www.webassociates.com
-----Original Message-----
From: Jim McAtee [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 13 April 2005 11:01 AM
To: CF-Talk
Subject: Regex help
(CF5 on IIS, Win2k Server)
I have a CF template set up as the IIS 404 error handler on a web site.
When IIS detects a 404 error it calls the CF page and passes the original
request within the CGI variable cgi.query_string in the following form:
404;http://www.mydomain.com/missingpage.htm
or if the request was for a directory it might look like:
404;http://www.mydomain.com/missingdirectory/
In my template I need to extract what would have been the original
cgi.path_info:
/missingpage.htm
or
/missingdirectory/
What might a CF function look like using regexes to extract the trailing
part of the URL? There will be many different host (domain) names pointed
at the site, so I can't match the domain name. The function would be called
by passing cgi.query_string:
<cfset path_info = getPathInfo(cgi.query_string)>
The function below is start, but it matches the entire string rather than
"extracting" just the end part.
function getPathInfo(qs) {
var re = '404;http://[^/]+/*';
var stuff = REFindNoCase(re, qs, 1, 'yes');
if (stuff.pos[1]) {
return Mid(qs, stuff.pos[1], stuff.len[1]);
} else {
return '';
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:202515
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54