Copy link to clipboard
I'm using regex (REreplaceNoCase()) to set the file path of the root of a site that I'm working on. Until now, it has worked great.
What I'm doing is using ExpandPath() to set an application variable in application.cfc so that no matter what folder under the webroot is being used, the variable will always have the same value, no matter if on DEV, Staging, or Production environment.
So, let's say one server in each environment: ServerA, ServerB, ServerC, respectfully.
The webroot on ServerA is C:\web\webdocs\myproject\
The webroot on ServerB is C:\web\webdocs\myproject\preview\
The webroot on ServerC is F:\hosting\www\public_html\myproject\docs\
I need a regex mask to point to the root on all three servers without hardcoding it, because, you know.. things are constantly changing, and you don't always know that paths will remain as is.
The following _kind of_ works:
<cfset application.wrmap = REreplaceNoCase(ExpandPath('./', (.+[\\|\/]myproject[\\|\/])(.+)', '\1','all') />
So.. no matter which server I'm on, the wrmap variable will point to [drive]:\path\to\myproject. But I need to get it to point to that plus /preview on one server, and /docs on another.
<cfset application.wrmap = REreplaceNoCase(ExpandPath('./', (.+[\\|\/]myproject([\\|\/][docs|preview])?[\\|\/](.+)', '\1','all') />
But it doesn't see /docs or /preview. Does anyone have any ideas, on this?
Have something to add?