I want to replace this titles:
Page 1 - example.com
Page 2 - example.com
Search engine optimization - example.com
I don’t want to replace this titles:
Page 1
Page 2
Search engine optimization
So only if the contain example.com then I want to replace it. I’ve tried something like this:
$document = preg_replace('#(<title[^>]*>)(.*)[(example.com)][^<]+</title>#i', '$1Welcome to my site</title>', $document);
But that is not working. Somebody has an answer?
Thanks in advance.
1 Answer