regex - How to replace src with regular expression and jquery -
i have following output. <img width='70' height='70' class='centreimg' src="http://localhost/aktivfitness_new/assets/images/centre/centre1.jpg" /> there same outputs centre2.jpg etc. want replace centre1.jpg hover.jpg when hover. but when use following becomes centre1hover.jpg $(".centreimg").mouseover(function() { var hoverimg = $(this).attr("src").match(/[^\.]+/) + "hover.jpg"; ... something wrong match(/[^.]+/) + "hover.jpg part. how can this? thanks in advance. don't think easier: var newsrc = oldsrc.replace(/[^\/\.]+\./, 'hover.'); anyway: shouldn't use javascript hovers =) if there way: use it. not bad practice, it's not user friendly: when image loads when hover, user see 'flash' because entire image still has loaded = not pretty.