This is a bit safer:
$('img').each(function () {
var src = $(this).attr('src');
$(this).attr('src', src.replace(/_m(\.[^.]+)?$/, '_t$1');
});
If you use eKek0, you could jeopardize a URL such /bat_man/images/oh_my_god_m.pngas /bat_tan/images/oh_my_god_m.png.
Regular expression explanation /_m(\.[^.]+)?$/:
/.../ - these are just the borders of the picture._mmatches literal _m.(...) , $1 .\. .. . char , \.[...] .^. , .. , .+ .? ( , ).$ (, , ).