RegEx not behaving as expected
Hello, all,
I think I may have posted regarding this issue, before, but didn't get any response; I (unfortunately) have to try, again.
I am using a Regular Expression to map the full physical location on the HD of where the website is located. I need this for a CFFILE tag.
The reason I'm using a RegEx instead of hard coding the location is because the location varies depending upon whether it is being used in development, staging, or production. (Yeah, I know.. all three should be mirrors of each other - I'm working on that.
)
For example, our DEV environment needs the CFFILE tag to point to E:\ColdFusion10\cfusion\wwwroot\www\ folder.
Our staging environment needs the CFFILE tag to point to C:\ColdFusion10\cfusion\www\ folder.
Our production environment needs the CFFILE to point to F:\webdocs\cf\www\docs\ folder.
I really do NOT want to be hackish about this and use a CFIF or CFSWITCH to set the "this.webrootmapping" variable. Besides, if anything gets changed, I'd have to go in and change the code. Not ideal.
So, I'm using a RegEx. I'm also setting it so that it will always point to the ROOT, no matter what sub-folder the user is in.
What I have (and isn't working for the production environment) is:
<cfset this.webrootmapping = REreplaceNoCase(ExpandPath('./'),
'(.+[\\|\/]www([\\|\/]docs)?[\\|\/])(.+)',
'\1',
'all') />
What this is supposed to do is accept everything up to the "www" folder, or up to "www\docs" folder, and remove everything after that.
It's working in dev and staging; it is NOT working in production (where the root ends in "\docs\".) The question mark should be indicating "zero or one of \docs". But it isn't.
Any insight greatly appreciated.
V/r,
^_^
