htmlregexwbr

Regex with long HTML strings and <wbr>


I just found the <wbr> element (link) which basically lets specific an area where a break could apply if needed.

Basically I'd like to implement it in my apps, to prevent breaking the layout due a comment in a blog with too many letters or signs.

The problem is: it has to be HTML compatible, so averylongmadeupandunnecesaryunspacedword might break apart each 25 characters but it won't break a link <a href="http://www.google.com/search?hl=en&source=hp&q=averylongandunnecesarywordingoogle&aq=f&aql=&aqi=&oq=">link</a>.


Solution

  • Have you considered using CSS? The word-wrap property is supported in IE, Safari, and FireFox 3.5

    /* example */
    .comments { word-wrap: break-word }
    

    Also, <wbr> isn't supported on IE8 :(