I need help for optimizing my regex for processing URL BBCode Tag. The regex is to check that URL tag has valid pattern and NOT containing whitelist protocol
#(\[url=(?:"|"|\'|)(((((?!https|http|ftp|mailto).)*):(//)?)([^\[\]]*))(?:"|"|\'|)\])(.*)(\[/url\])#siU
Regex will ignore :
- [url="www.example.com"]example[/url]
- [url="https://example.com"]example[/url]
- [url="http://example.com"]example[/url]
- [url="ftp://example.com"]example[/url]
- [url="mailto:mail@example.com"]example[/url]
And match when :
- [url="ymsgr://example.com"]example[/url]
- [url="anyprotocol://example.com"]example[/url]
It's run well and has no issue, until user create string data with more than 10000 char length, that will make Catastrophic backtracking