komanda icon indicating copy to clipboard operation
komanda copied to clipboard

Regexp for images (and others?) are confused by nearby punctuation

Open jimallman opened this issue 11 years ago • 2 comments

These chat messages will embed the specified image:

http://i.imgur.com/aNRAMkp.gif

test test http://i.imgur.com/aNRAMkp.gif

test http://i.imgur.com/aNRAMkp.gif test

... but this one fails (presumably because of the trailing parenthesis):

(i usually add text around them, like this: http://i.imgur.com/aNRAMkp.gif) 

jimallman avatar Aug 24 '14 20:08 jimallman

See the last regex entry in this discussion: http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/

This works by only allowing matching parenthesis in a URL. So, you don't have to worry about the above case.

I'll look at this more in the next few days, unless someone beats me to it. :)

tbpalsulich avatar Aug 25 '14 01:08 tbpalsulich

I just pushed a PR for this.

h0lyalg0rithm avatar Aug 25 '14 07:08 h0lyalg0rithm