I'm currently using this regular expression to capture all URLs in a string, which could be multiple lines and contain any other sort of text, which is working perfectly for normal URLs. But I want to replace image URLs in a different way, so my current expression can't match those URLs.
My current expression is
(https?:\/\/([-\w\.]+[-\w])+(:\d+)?(\/([\w\/_\.#-]*(\?\S+)?[^\.\s])?)?)
But I don't want it to match URLs that end with (jpe?g|png|gif), and I haven't been able to figure out exactly how to use the RegEx negative lookaheads.
(?!\S+(?:png|gif|jpe?g))which will force a url to not match if it has.(png|gif|jpe?g)anywhere in the string. Example