I need to get "yomomedia.com" if the HTTP_HOST is [ANY].yomomedia.com except in the cases where it is "dev.yomomedia.com" else it should return dev.yomomedia.com
echo preg_replace("/^([EVERYTHING-OTHER-THAN-DEV])\./Ui","",$_SERVER['SERVER_NAME'])
Just tried the following with no success:
echo preg_replace("/^(?!dev)\./Ui",'','www.yomomedia.com'); // returns www.yomomedia.com
echo preg_replace("/^(?!dev)\./Ui",'','dev.yomomedia.com'); // returns dev.yomomedia.com
A negative passive group (lookahead) should do:
/^(?!dev).*\./Ui
Look-arounds do not “consume” any characters. So your expression means the same as the first three characters are not dev
(^(?!dev)
) AND the first character is a full stop (^\.
).
So try either this:
/^(?!dev\.)[^.]+\./Ui
Or:
/^[^.]+\.(?<!^dev\.)/Ui