Reputation: 566
I need a Regular Expression to accept the URL ending with all file Types: Like "http://other-images.contenix.com/BrandAssets/55957/care_guide.pdf" or "http://upload.wikimedia.org/wikipedia/commons/9/9a/Avenger_-_Westphalian_horse.jpg" .
I have tried this: "^..(gif|jpg|jpeg|png|bmp|GIF|JPEG|JPG|PNG|BMP|Gif|Jpg|Jpeg|Png|Bmp)\s$", but this only allows only image file.
Now my requirement has changed for all File Types.
****EDIT
Can i make something like there should be a "." among the characters after the URL final slash "/"
Any Help Appreciated.
Thanks
Upvotes: 1
Views: 119
Reputation: 174766
To match all the URL's which contain a dot after the final /
symbol is as below.
^.*\/[^.]*\.\w+\s*$
Upvotes: 1
Reputation: 11116
Thats a tricky question because the types of files can be many .. as many as .. may be 500+ you can check out the list here
Better off list all the file formats that you are to allow, and then just keep on adding them with a |
(pipe). As you have done for image extensions.
To make sure that your url will contain a dot use :
^.*?\.\w+$
demo here : http://regex101.com/r/sL8vF1/1
Upvotes: 1