RE: [Flashcoders] Found an AS3 RegExp Bug.

2007-06-09 Thread Benny
Hi Isaac,

/[^\\]'/ 
Is interpreted as match any character that isn't a back slash and that is
followed by a single quote

So in "alert('foo');" the first character that is not \ and is followed by '
is the first (

so the total match is (' which is replaced by \' which results in:
alert\'foo');

The same applies to your second replace statement, where the match is o'
(again first non back slash followed by single quote) which is replaced by
\' and now results in alert\'fo\');

- Benny

P.S. within a character class there is no need to escape the \ because in
there it has no special meaning, so you can write /[^\]'/

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Isaac Rivera
Verzonden: zaterdag 9 juni 2007 20:00
Aan: flashcoders@chattyfig.figleaf.com
Onderwerp: Re: [Flashcoders] Found an AS3 RegExp Bug.

Thank you benny. I can see how this works, but why does my pattern(/[^ 
\\]'/) does not?


Isaac Rivera
Technology Director :: Experience Design Group
America Online :: New York City
p 212 652-6308 :: c 347 342-2195


On Jun 9, 2007, at 1:30 PM, Benny wrote:

> var code:String = "alert('foo');";
> code = code.replace(/'/g,"\\'");
> trace(code);

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


__ NOD32 2320 (20070609) Informatie __

Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Found an AS3 RegExp Bug.

2007-06-09 Thread Isaac Rivera
Thank you benny. I can see how this works, but why does my pattern(/[^ 
\\]'/) does not?



Isaac Rivera
Technology Director :: Experience Design Group
America Online :: New York City
p 212 652-6308 :: c 347 342-2195


On Jun 9, 2007, at 1:30 PM, Benny wrote:


var code:String = "alert('foo');";
code = code.replace(/'/g,"\\'");
trace(code);


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Found an AS3 RegExp Bug.

2007-06-09 Thread Benny
The results you get are as expected.
To get the output you desire try:

var code:String = "alert('foo');";
code = code.replace(/'/g,"\\'");
trace(code);

- Benny

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Isaac Rivera
Verzonden: zaterdag 9 juni 2007 19:09
Aan: flashcoders@chattyfig.figleaf.com
Onderwerp: Re: [Flashcoders] Found an AS3 RegExp Bug.

Let me correct a paste mistake there:

THE FOLLOWING CODE:

var pattern:RegExp = /[^\\]'/;
var code:String = "alert('foo');";
code = code.replace(pattern, "\\'");
code = code.replace(pattern, "\\'");

traces: "alert\'fo\');"

Should it not trace: "alert(\'foo\');" instead?

Isaac Rivera
Technology Director :: Experience Design Group
America Online :: New York City
p 212 652-6308 :: c 347 342-2195


On Jun 9, 2007, at 1:04 PM, Isaac Rivera wrote:

> The following code:
>
> var pattern:RegExp = /[^\\]'/;
> var code:String = "alert(\'foo\');";
> code = code.replace(pattern, "\\'");
> code = code.replace(pattern, "\\'");
>
> traces "alert\'fo\');" instead of "alert(\'foo\');"
>
> Isaac Rivera
> Technology Director :: Experience Design Group
> America Online :: New York City
> p 212 652-6308 :: c 347 342-2195
>
>
> ___
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


__ NOD32 2320 (20070609) Informatie __

Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Found an AS3 RegExp Bug.

2007-06-09 Thread Isaac Rivera

Let me correct a paste mistake there:

THE FOLLOWING CODE:

var pattern:RegExp = /[^\\]'/;
var code:String = "alert('foo');";
code = code.replace(pattern, "\\'");
code = code.replace(pattern, "\\'");

traces: "alert\'fo\');"

Should it not trace: "alert(\'foo\');" instead?

Isaac Rivera
Technology Director :: Experience Design Group
America Online :: New York City
p 212 652-6308 :: c 347 342-2195


On Jun 9, 2007, at 1:04 PM, Isaac Rivera wrote:


The following code:

var pattern:RegExp = /[^\\]'/;
var code:String = "alert(\'foo\');";
code = code.replace(pattern, "\\'");
code = code.replace(pattern, "\\'");

traces "alert\'fo\');" instead of "alert(\'foo\');"

Isaac Rivera
Technology Director :: Experience Design Group
America Online :: New York City
p 212 652-6308 :: c 347 342-2195


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Found an AS3 RegExp Bug.

2007-06-09 Thread Isaac Rivera

The following code:

var pattern:RegExp = /[^\\]'/;
var code:String = "alert(\'foo\');";
code = code.replace(pattern, "\\'");
code = code.replace(pattern, "\\'");

traces "alert\'fo\');" instead of "alert(\'foo\');"

Isaac Rivera
Technology Director :: Experience Design Group
America Online :: New York City
p 212 652-6308 :: c 347 342-2195


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com