I use the the following pattern in preg_replace() to replace a specific domain name from the beginning of all paths in html file. Everything is fine, but the problem is that it replaces the domain names in email addresses also.
preg_replace('%(https?://)?(www\.)?domain\.com/?%im', '', '$html')
Result shold be like:
domain.com/path/ => /path/
www.domain.com/path/ => /path/
beginning of file path in html file; or provide a functional example string? Also themmodifier isn't doing anything in your expression.%(https?://)?(?<!@)(www\.)?domain\.com/?%imnegating the@?example.com-the-email-address andexample.com-the-web-url+althoughhttps://https://www.domain.comwould be strange. The?made it optional; just removing that requires it be present once.