[thelist] Error in regular expression on IE for Mac

Allan Lund Jensen allan at balthazar.dk
Tue Feb 5 04:46:01 CST 2002


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.
--
[ Picked text/plain from multipart/alternative ]
Hi,

I tried asking in the microsoft IE mac newsgroup, but I didn't get an
answer, so I hope someone here can help ;)

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