going for a split that when concatenated returns the original ... \b is what I tried... it works for all but opera. I didn't care that safari thinks there's an extra at the end... but when Opera came back with 15 (each character).... I laughed!
"hello there Opera" should split into 5 strings , 2 of which are the blanks. On 6/10/07, Michael Geary <[EMAIL PROTECTED]> wrote:
What result you are looking for? \b and \s+ are radically different from each other. \b is an anchor that matches no characters. \s+ is a pattern that matches one or more whitespace characters. It's kind of unusual to use a non-matching anchor like \b in a .split, so I guess it's not too surprising that each browser gets it different. Parenthesizing the \s+ changes things a lot too. The parentheses mean that you want the matching delimiter strings to show up in the result array. If you just want to split the string into words, delimited by any amount of whitespace, use .split(/\s+/) - but is that the result you want? "hello there Opera".split(/\s+/).length should be 3 in any browser. (I added some spaces for illustration.) -Mike > javascript:alert("hello there Opera".split(/\b/).length) > > Firefox says 5 , safari says 6, Opera says 15! > > it really got me confused while writing some jQuery code! > > now I use $.browser.opera ? /(\s+)/ : /\b/ ; instead. > > Ouch, I didn't realize there was that much of a difference!
-- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ