I'm having troubles constructing a regular expression using ColdFusion 10. I need reFind() to return zero if a URL contains "dev" at the end of any subdomain with "mydomain.com" in it.
reFind(THE_REGEX, "subdomaindev.mydomain.com") needs to return 0
reFind(THE_REGEX, "subdomain.mydomain.com") needs to return a positive number
I found the following on Adobe's documentation: (http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec0a38f-7ffb.html) and based on that I tried to use the lookahead concept.
Thought this would work, but it doesn't:
reFind("(?!dev)\.mydomain\.com$", "subdomaindev.mydomain.com") = 13
reFind("(?!dev)\.mydomain\.com$", "subdomain.mydomain.com") = 10
Don't understand why this gives zero for both:
reFind("(?=dev)\.mydomain\.com$", "subdomaindev.mydomain.com") = 0
reFind("(?=dev)\.mydomain\.com$", "subdomain.mydomain.com") = 0
This is the results I expected from (?=):
reFind("(?:dev)\.mydomain\.com$", "subdomaindev.mydomain.com") = 10
reFind("(?:dev)\.mydomain\.com$", "subdomain.mydomain.com") = 0
NOTE: this is for use with ColdBox's environment config where I can only pass a single regular expression to a variable called "environments" that then calls a method for the matched environment. I would prefer not to have a second check in that method to find the "dev.", but if I must I will.
Thank you for any help!