found this code for find and replace
var f = ['Rd','St','Ave'];
var r = ['Road','Street','Avenue'];
var re = $.map(f, function(v,i) {
return new RegExp('\\b' + v + '\\b', 'g');
});
jQuery('#colCenterAddress').val(function(i,val) {
$.each(f,function(i,v) {
val = val.replace(re[i],r[i]);
});
return val;
});
jQuery find and replace with arrays thanks to https://stackoverflow.com/users/1106925/squint
its really great but i would like to refactor to use a key value array
var fr ={
"Rd" : "road",
"St" : "Street",
"Ave" : "Avenue",
};
firly new to jQuery any help would be great
Try
Demo: Fiddle