I am trying the match part of an image src, an example would be:
images/preview_1.jpg
and I want to change _1 to say _6
so I’m trying to match _1
function ClickImgOf(filename, itemid){
var re = new RegExp("(.+)_[0-9])\\.(gif|jpg|jpg|ashx|png)", "g");
return filename.replace(re, "$1_"+itemid+".$2");
}
Is the function I have..
I know that only matches 0-9 but I was just trying to get something to work and even that didn’t.
Its fair to say I do not know much about Regex at the moment.
You have an unmatched
)parenthesis there in your pattern. Is that what’s throwing you off? Looks okay otherwise. If your problem is being able to match 2-or-more-digit numbers, try[0-9]+.