title: jQuery find and replace with key value arrays
body: <p>found this code for find and replace </p>
  
  <pre><code>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;
  });
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/8881436/jquery-find-and-replace-with-arrays">jQuery find and replace with arrays</a>
  thanks to 
  <a href="https://stackoverflow.com/users/1106925/squint">https://stackoverflow.com/users/1106925/squint</a></p>
  
  <p>its really great but i would like to refactor to use a key value array</p>
  
  <pre><code>var fr ={ 
   "Rd" : "road",
   "St" : "Street",
   "Ave" : "Avenue",
   };
  </code></pre>
  
  <p>firly new to jQuery any help would be great</p>