AlbaStar AlbaStar - 1 month ago 18
Javascript Question

Matching images with regex in ubot

I'm trying to match only images with same resolution using regex in ubot studio.

Sample image urls that I want to match:

http://sample.com/Image/e7b89db921da411bae9eea3c1333f287/201605/word/word/640/480/imagename.jpeg
http://sample.com/Image/a3c133e411bae9ee3f287b89db921da7/201504/word/word/640/480/imagename2.jpeg
http://sample.com/Image/41187b89db921dbae9ee3f2a3c133ea7/201505/word2/word/640/480/imagename3.jpeg


but to don't match images like:
http://sample.com/Image/fdsfsdf.jpeg or other images.
I've started with
^(http.+)\.jpeg$
but this is matching all images.
I need something like this:

http://sample.com/Image/*/*/word/word/640/480/*.jpeg

Answer

One of your url contains word2, so your regex does not match.

Try this one http:\/\/sample.com\/Image\/.*?\/.*?\/word2?\/word\/(\d+)\/(\d+)\/.*?\.jpeg

Sample