i need to use preg_replace to replace two subdomain elements with a single element. my regex skills are virtually nonexistent. the urls are of the form:
user1.common.domain.org
user2.common.domain.org
something.common.domain.org
else.common.domain.org
and need to be replaced with:
newvalue.domain.org
preg_replace( '/[a-z0-9]+\.common/i' , 'newvalue' , $url );
Try this:
preg_replace("/.+?(domain.+?)/", "newvalue.$1", "user1.common.domain.org");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With