I am trying to replace hyphens in text to non-breaking hyphens, but I need to exlude all URLs, emails and tags. Here is some text I am trying to edit:
Some text with a link but also plain URL like http://another-domain.com and an e-mail [email protected] and e-shop and some relative URL like /test-url/on-this-website.
and I came up with this regex: (^|\s+)[^@|^\/]+(\s+|$)
But it cannot be used for preg_replace, it doesn't match hyphens, but whole text that contains dashes.
Result should be:
Some text with a <a href="https://some-domain.com/section-name" class="some-class">link</a> but also plain URL like http://another-domain.com and an e‑mail [email protected] and e‑shop and some relative URL like /test-url/on-this-website.
Have anyone been doing something similar?