After looking (Googling) on the web for a while, I can find nothing that takes an address like:
1200 Pennsylvania Ave SE, Washington, District of Columb
Borrowing from Michael Jasper's and Jon Hendershot's solutions, I offer the following:
$('address').each(function() {
var text = $(this).text();
var q = $.trim(text).replace(/\r?\n/, ',').replace(/\s+/g, ' ');
var link = '';
return $(this).wrapInner(link);
});
This solution offers the following benefits over solutions previously offered:
tags) within , so formatting is preserved which is invalid because block-level elements such as are not permitted within inline elements such as .Caveat: If your Then it'll work just fine. tag contains block-level elements like or tag will contain those block-level elements). But if you're just doing stuff like this:
The White House
1600 Pennsylvania Ave NW
Washington, D.C. 20500