Regex for skipping specified URL extensions

regex

Solution

If lookbehind is supported then this regex should work:

^\S+$(?<!\.(?:ex1|ex2|ex3)$)

Live Demo: http://www.rubular.com/r/gQDxYdDKcU

If lookbehind isn't supported (e.g. Javascript) then use this lookahead based regex:

^(?!.*?\.(?:ex1|ex2|ex3)$)\S+$

Live Demo: http://www.rubular.com/r/S0FGAETLr2

Problem

I have a link. Ex: http://my.domain/url.jsp My goal is create patter that will be not allow any URLs with extension like this: `.ex1, .ex2, .ex3` I was searching a long of time and find some approach, but it's really opposite that I want. ``` ([^\s]+(\.(?i)(ex1|ex2|ex3))$) ```

Original source