views:

821

answers:

2

Is there a reason why the following piece of code doesn't work in IE? While with FF and other sane browsers it splits the string by the given expression, in IE it simply doesn't work.

var str = "abc<font id=\"something\">def</font>gh";
alert(str.split(/(\<.*?\>|.)/).length);

Thank you.

+2  A: 

Perhaps this page is of use:

http://blog.stevenlevithan.com/archives/cross-browser-split

spender
I wonder, are those kind of idiotic stuff in IE are bugs or features decided by the management? I guess IE 8 sucks just as well!
thedp
JOKE ON: Bugs for programmers are new and exciting features for commercials.
ATorras
A: 

Hi,

Maybe you should use the RegExp object like the second example of http://msdn.microsoft.com/en-us/library/h6e2eb7w%28VS.85%29.aspx.

Regards.

ATorras
It has nothing to do with it. The problem is the existence of a regular expression, not the way it is passed to the split method.
thedp
I'm sorry I didn't express well; I just wanted to point the way the regexp is created, not the regexp expression itself.IIRC I fixed some regexp problems creating the RegExp object, instead of using the /.../ format.
ATorras