I want to remove all links from a text and replace them with a subsitute that are starting with the protocols "example://" and "example_two://". All other links shall be untouched.
The following regex will replace all links despite of the fact that I limit the link types:
(\<a).+?(example|example_two)?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))(.+?)</a>+"
Has anyone a suggestion what is required to change the regex to work as expected?
source https://stackoverflow.com/questions/70804746/remove-all-links-with-a-specific-protocol-with-regex
Comments
Post a Comment