[thelist] Error in regular expression on IE for Mac

Sam sam at sam-i-am.com
Tue Feb 5 08:33:02 CST 2002


looks like you are writing a simple compression algorithm... I went down
this road last year and came across similar problems with the regexp
engine in Mac IE5, and failed to find any documentation on what it's
truly capable of, and where it differs from its win32 cousin.
but I think I got *something* kind of working (though it never got
finished in time for the
5k competition), i'll poke around and see what I can turn up.

so, no answers but some solidarity :)

Allan Lund Jensen wrote:
>
> This message is in MIME format. Since your mail reader does not understand
> this format, some or all of this message may not be legible.
> Using a regular expression I want to replace all occurences of 3 or more
> identical characters following each other with, for example, "x".
> So, the string:
> "1442455556333"
> would after doing a replace look like this:
> "14424x6x"
>
> My expression looks like this:
> var re                  = /(.)\1\1+/g;
>
> This causes IE to report an error ( "Unexpected quantifier" ). I think it
> stumbles on the "+".
> The above expression only fails in IE for Mac, and not using Windows or
> Netscape 6.
>
> To be fair I also tried using "new RegExp" ( and thus removing the g flag ).
> I think it looked a bit like this:
> var re = new RegExp( "(.)\\1\\1+" , "g" );
> (Im not sure this is what I ended up with, as I'm writing from home, not
> work ).
> In any case the above also worked in IE for Windows and Netscape 6, but not
> IE for Mac.
>
> So I guess the question buried in this mess is actually 2 questions:
> 1) Is there another way to write my expression that IE for Mac will accept.
> 2) Is the expression correct?
>
> Now, I am aware that there are other way to achieve the wanted result (using
> a loop ), but unless I'm mistaken, those other solutions would be longer,
> and since size is a factor, I really need to do this using regular
> expressions.
>
> Hope someone can help,
>
> Allan



More information about the thelist mailing list