I need help with my javascript code.
var mapObj = {
rd:"road",
st:"street",
};
var re = new RegExp(Object.keys(mapObj).join("|"),"gi");
package_street_name = package_street_name.toLowerCase().replace(re, function(matched){
return mapObj[matched];
});
What it does basically replace "rd" with "road", and "st" with "street". How can I make it so that it should replace only the exact word?
For example. If its Verdana Rd. it should result in Verdana Road
My current code, it results in Veroadana Road.