[jQuery] Re: [ot] String.split in Opera.

2007-06-11 Thread John Beppu

Isn't Javascript supposed to support Perl-compatible regular expressions?

Perl says the answer is:  5

perl -e 'print scalar split(/\b/, hello there Opera)'



On 6/10/07, Ⓙⓐⓚⓔ [EMAIL PROTECTED] wrote:


WWIED? What would IE do?

On 6/10/07, Matt Stith [EMAIL PROTECTED] wrote:

 o.O damn, like you said, i didnt know there was that big of a
 difference!

 On 6/10/07, Ⓙⓐⓚⓔ  [EMAIL PROTECTED]  wrote:
 
  safari says 3 for
  javascript:alert(hello there Opera.split(/(\s+)/).length)
 
 
  On 6/10/07, Matt Stith  [EMAIL PROTECTED] wrote:
  
   why not just use /(\s+)/ in firefox too then? It gives me the
   correct number of 5.
  
   On 6/10/07, Ⓙⓐⓚⓔ  [EMAIL PROTECTED] wrote:
   
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!
   
   
  
 
 
  --
  Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ





--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ


[jQuery] Re: [ot] String.split in Opera.

2007-06-10 Thread Matt Stith

why not just use /(\s+)/ in firefox too then? It gives me the correct number
of 5.

On 6/10/07, Ⓙⓐⓚⓔ [EMAIL PROTECTED] wrote:


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!




[jQuery] Re: [ot] String.split in Opera.

2007-06-10 Thread Ⓙⓐⓚⓔ

safari says 3 for
javascript:alert(hello there Opera.split(/(\s+)/).length)


On 6/10/07, Matt Stith [EMAIL PROTECTED] wrote:


why not just use /(\s+)/ in firefox too then? It gives me the correct
number of 5.

On 6/10/07, Ⓙⓐⓚⓔ  [EMAIL PROTECTED] wrote:

 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!






--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ


[jQuery] Re: [ot] String.split in Opera.

2007-06-10 Thread Matt Stith

o.O damn, like you said, i didnt know there was that big of a difference!

On 6/10/07, Ⓙⓐⓚⓔ [EMAIL PROTECTED] wrote:


safari says 3 for
javascript:alert(hello there Opera.split(/(\s+)/).length)


On 6/10/07, Matt Stith  [EMAIL PROTECTED] wrote:

 why not just use /(\s+)/ in firefox too then? It gives me the correct
 number of 5.

 On 6/10/07, Ⓙⓐⓚⓔ  [EMAIL PROTECTED] wrote:
 
  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!
 
 



--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ


[jQuery] Re: [ot] String.split in Opera.

2007-06-10 Thread Ⓙⓐⓚⓔ

WWIED? What would IE do?

On 6/10/07, Matt Stith [EMAIL PROTECTED] wrote:


o.O damn, like you said, i didnt know there was that big of a difference!

On 6/10/07, Ⓙⓐⓚⓔ [EMAIL PROTECTED]  wrote:

 safari says 3 for
 javascript:alert(hello there Opera.split(/(\s+)/).length)


 On 6/10/07, Matt Stith  [EMAIL PROTECTED] wrote:
 
  why not just use /(\s+)/ in firefox too then? It gives me the correct
  number of 5.
 
  On 6/10/07, Ⓙⓐⓚⓔ  [EMAIL PROTECTED] wrote:
  
   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!
  
  
 


 --
 Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ






--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ


[jQuery] Re: [ot] String.split in Opera.

2007-06-10 Thread Ⓙⓐⓚⓔ

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 thereOpera.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!





--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ


[jQuery] Re: [ot] String.split in Opera.

2007-06-10 Thread Matt Stith

IE would throw an exception and try to install adware on your computer. :P

On 6/10/07, Ⓙⓐⓚⓔ [EMAIL PROTECTED] wrote:


WWIED? What would IE do?

On 6/10/07, Matt Stith [EMAIL PROTECTED] wrote:

 o.O damn, like you said, i didnt know there was that big of a
 difference!

 On 6/10/07, Ⓙⓐⓚⓔ  [EMAIL PROTECTED]  wrote:
 
  safari says 3 for
  javascript:alert(hello there Opera.split(/(\s+)/).length)
 
 
  On 6/10/07, Matt Stith  [EMAIL PROTECTED] wrote:
  
   why not just use /(\s+)/ in firefox too then? It gives me the
   correct number of 5.
  
   On 6/10/07, Ⓙⓐⓚⓔ  [EMAIL PROTECTED] wrote:
   
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!
   
   
  
 
 
  --
  Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ





--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ