javascript - Replace sub string in a string with specific value jQuery -
hi please me replace sub string of following url using jquery. following url have '/s320', in sub string '/s' constant after '/s' numeric value '320' or '200' or other numeric value, numeric value may varies.
now want replace '/s***(3 digit numeric value)' '/s1600'
input strings: http://3.bp.blogspot.com/-dpywtw6oqg0/uis1rsekwci/aaaaaaaac10/_uo_pfhexhw/s320/pawan+kalyan+birthday+special+latest+posters++(2).jpg
/s320 : may /200 or /100 or numeric value of length = 3
output stings want url above urls.
http://3.bp.blogspot.com/-dpywtw6oqg0/uis1rsekwci/aaaaaaaac10/_uo_pfhexhw/s1600/pawan+kalyan+birthday+special+latest+posters++(2).jpg
if don't regex can use split , substr
function replaceparam(x){ var = x.indexof("/s"); return x.slice(0,i) + "/s1600" + x.substr(i+5); } replaceparam("http://3.bp.blogspot.com/-dpywtw6oqg0/uis1rsekwci/aaaaaaaac10/_uo_pfhexhw/s320/pawan+kalyan+birthday+special+latest+posters++(2).jpg");
Comments
Post a Comment