12.05.08
A Big Space in between Firefox and Internet Explorer
For those of you who tried to put together a “flatten” function cross browser to eliminate consecutive spaces and/or trim some text that is retrieved from the HTML page itself, you might have noticed that a simple regex of the kind
/\s+/gm
is simply not enough and occasionally Internet Explorer would still return a string with multiple consecutive space characters! The reason for that is that Internet Explorer does NOT treat
(non-breaking spaces) as a space — and therefore the \s won’t match it! In order to include this in your match, look at W3C list of HTML entities, and it transpires that is the same as — in other words 160 is the decimal code for this character (which is A0 in hex by the way). So to include this when searching for spaces, your regex now becomes:
/(\s|\xA0)+/gm
and you’ll notice that now you “catch” the non-breaking spaces in IE as well as Firefox (which does the right thing and treats the non-breaking spaces as proper spaces) — yahoo!

Explorer » A Big Space in between Firefox and Internet Explorer said,
May 12, 2008 at 6:15 pm
[...] liviu.tudor wrote an interesting post today on A Big Space in between Firefox and Internet ExplorerHere’s a quick excerpt… and/or trim some text that is retrieved from the HTML page itself, you might have noticed that a simple regex of the kind /s+/gm is simply not enough and occasionally Internet Explorer would still return a string with multiple [. … [...]
Amit said,
September 8, 2008 at 5:26 pm
Yet another IE drawback.Thanks for the post..was going nuts,wondering y IE doesnt remove