11548 sujets
Salut,
Quelque chose comme ça ?
Quelque chose comme ça ?
var url = "images/album12/image15.jpg",
seg = url.split(/\/|\./);
// augmente y
seg[2] = "image" + (parseInt(seg[2].substring(5)) + 1); //5 correspond au nombre de à sauter (nb caractères dans "image")
// augmente x
//seg[1] = "album" + (parseInt(seg[1].substring(5)) + 1);
seg[2] += "."+seg.pop();
alert(seg.join("/"));
Ou encore :
http://code18.blogspot.com/2009/09/lookahead-dans-une-regex.html
alert(url.replace(/(\d+)(?=\.jpg$)/, function(n) { return +n + 1; }));
http://code18.blogspot.com/2009/09/lookahead-dans-une-regex.html