Sunday, 15 August 2010

Javascript regex remove everything after .extension -



Javascript regex remove everything after .extension -

i have next sample url need sanitize

http://image.s5a.com/is/image/saks/0447522591096_647x329.jpg" border="0" params="">

into

http://image.s5a.com/is/image/saks/0447522591096_647x329.jpg

my question is, regex should utilize flexibly remove after .extension, regardless of whether .jpg, or .png or .jpeg?

also texts , symbols after extension different.

thanks

(.*?(?:jpg|png|jpeg))|.*

try this.replace $1.see demo.

http://regex101.com/r/rq6mk9/47

javascript regex

No comments:

Post a Comment