[flexcoders] Re: Why Doesn't This JavaScript Regular Expression Work in AS3?

2008-08-11 Thread jwebbsuccess
Josh,

You're pretty awesome off the top of your head.  Your change works. 
Thanks a bunch.

Do you have a general statement about the difference between JS and
AS3 regular expressions by chance?


--- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] wrote:

 Off the top of my head:
 
 var regex = /^true,\s*\$/;
 
 result = regex.test(str);
 
 On Mon, Aug 11, 2008 at 3:54 AM, jwebbsuccess [EMAIL PROTECTED]wrote:
 
  Exactly, haykelbj.  What I need help with is rewriting the regular
  expression for the isCurrency test so that the strings true,$ or
  true, $ will return true in AS3.  I'm not so hot at writing
  regexps...  isCurrency returns true on those two strings in
  JavaScript; I don't know why they return false in AS3.
 
 
 
  --- In flexcoders@yahoogroups.com, haykelbj haykelbj@ wrote:
  
   The JavaScript and ActionScript codes are not doing exactly the same
   thing. In your AS code, at a certain point you are doing the
following
   assignment:
   _testValue = qualifier.toLowerCase()+ ,$;
   This will result in _testValue = true,$ which will make the test
   isCurrency.test(_testValue) return false which is right because
   isCurrency's regex is /^, ?\$/.
  
  
   --- In flexcoders@yahoogroups.com, jwebbsuccess jwebb@ wrote:
   
I have a regular expression that works in JavaScript and does
not work
in ActionScript 3, even though both languages supposedly use the
ECMAScript standard for regular expressions.  I need the
expression to
return true when ever it tests the two strings below:
   
true,$
true, $
   
I need the expression to return false whenever the string is
not the
same as one of the two above.
   
I've attached the HTML that demonstrates that the regular
expressions
work in JavaScript.  Can you modify the same expressions in
the Flex
code, provided below, to produce the same result?
   
Thanks.
   
---
html
head
style type=text/css
#doc {background-color:#EFEFEF;text-align:center;}
#testBlock
   
  
 
{background-color:#FF;text-align:left;width:600px;height:500px;margin:
0 auto;border:1px solid #FF9900;padding:0 20px;}
.regexp {color:#FF;}
.testval {color:#00CC00;}
/style
/head
body id=doc
div id=testBlock
  h1 id=test1/h1
  h1 id=test2/h1
  h1 id=testValue/h1
  pThe only two true values should be true,$ and true, $;
everything else should be false./p
  script type=text/javascript
   
//TEST YOUR REGULAR EXPRESSIONS HERE.
  var re1 = /^true\b(.*)$/;
  var re2 = /^, ?\$/;
  var str = true,$;
   
//THE VALUES USED IN YOUR TESTS WILL APPEAR IN THE
PAGE...
  document.getElementById( test1 ).innerHTML =
Regular
  Expression
1: span class='regexp' + re1 + /span;
  document.getElementById( test2 ).innerHTML =
Regular
  Expression
1: span class='regexp' + re2 + /span;
  document.getElementById( testValue ).innerHTML
= Test
  Value:
span class='testval' + str + /span;
   
  if ( ( resultArray = re1.exec( str ) ) != null )
  {
alert( Test 1 successful );
if ( re2.test( resultArray[ 1 ] ) )
{
alert( Test 2 successful );
}
else
{
alert( Test 2 failed );
}
  }
/script
/div
/body
/html
   
---
   
?xml version=1.0?
!-- wrapper/GetURLInfo.mxml --
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
creationComplete=runRegExpTest( event )
mx:Script
![CDATA[
import mx.events.FlexEvent;
import mx.controls.Alert;
   
[Bindable] private var _test1:String = ;
[Bindable] private var _test2:String = ;
[Bindable] private var _testValue:String = ;
   
private function runRegExpTest( e:FlexEvent ):void
{
  var isTrue:RegExp =/^true\b(.*)$/;
  var isCurrency:RegExp =/^, ?\$/;
  var qualifier:String = TRUE;
  _test1 = isTrue.toString();
  _test2 = isCurrency.toString();
  var msg1:String;
  var msg2:String;
   
  if ( isTrue.test( qualifier.toLowerCase() ) )
  {
_testValue = qualifier.toLowerCase()+ ,$;
msg1 = The qualifier is:  +
qualifier.toLowerCase() + ,
the test value is (  + _testValue +  ) and returns:  +
isCurrency.test( _testValue ).toString();
trace( msg1 );
Alert.show( msg1 );
if ( isCurrency.test( _testValue ) )
{
  msg2 = The test is SUCCESSFUL!;
  

Re: [flexcoders] Re: Why Doesn't This JavaScript Regular Expression Work in AS3?

2008-08-11 Thread Josh McDonald
I don't really do much JS these days (yay!), but Flash's regex is pretty
close to the standard, but you've just gotta get your head in and out of
regex space and think of things like the beginning and end of the string,
as well as what you're trying to test, and what you're trying to match, etc.

Plus, I think JS has /g set by default, Flash doesn't. But that might be
wrong :)

-J

On Tue, Aug 12, 2008 at 3:56 AM, jwebbsuccess [EMAIL PROTECTED]wrote:

 Josh,

 You're pretty awesome off the top of your head.  Your change works.
 Thanks a bunch.

 Do you have a general statement about the difference between JS and
 AS3 regular expressions by chance?


 --- In flexcoders@yahoogroups.com, Josh McDonald [EMAIL PROTECTED] wrote:
 
  Off the top of my head:
 
  var regex = /^true,\s*\$/;
 
  result = regex.test(str);
 
  On Mon, Aug 11, 2008 at 3:54 AM, jwebbsuccess [EMAIL PROTECTED]wrote:
 
   Exactly, haykelbj.  What I need help with is rewriting the regular
   expression for the isCurrency test so that the strings true,$ or
   true, $ will return true in AS3.  I'm not so hot at writing
   regexps...  isCurrency returns true on those two strings in
   JavaScript; I don't know why they return false in AS3.
  
  
  
   --- In flexcoders@yahoogroups.com, haykelbj haykelbj@ wrote:
   
The JavaScript and ActionScript codes are not doing exactly the same
thing. In your AS code, at a certain point you are doing the
 following
assignment:
_testValue = qualifier.toLowerCase()+ ,$;
This will result in _testValue = true,$ which will make the test
isCurrency.test(_testValue) return false which is right because
isCurrency's regex is /^, ?\$/.
   
   
--- In flexcoders@yahoogroups.com, jwebbsuccess jwebb@ wrote:

 I have a regular expression that works in JavaScript and does
 not work
 in ActionScript 3, even though both languages supposedly use the
 ECMAScript standard for regular expressions.  I need the
 expression to
 return true when ever it tests the two strings below:

 true,$
 true, $

 I need the expression to return false whenever the string is
 not the
 same as one of the two above.

 I've attached the HTML that demonstrates that the regular
 expressions
 work in JavaScript.  Can you modify the same expressions in
 the Flex
 code, provided below, to produce the same result?

 Thanks.

 ---
 html
 head
 style type=text/css
 #doc {background-color:#EFEFEF;text-align:center;}
 #testBlock

   
  
 {background-color:#FF;text-align:left;width:600px;height:500px;margin:
 0 auto;border:1px solid #FF9900;padding:0 20px;}
 .regexp {color:#FF;}
 .testval {color:#00CC00;}
 /style
 /head
 body id=doc
 div id=testBlock
   h1 id=test1/h1
   h1 id=test2/h1
   h1 id=testValue/h1
   pThe only two true values should be true,$ and true, $;
 everything else should be false./p
   script type=text/javascript

 //TEST YOUR REGULAR EXPRESSIONS HERE.
   var re1 = /^true\b(.*)$/;
   var re2 = /^, ?\$/;
   var str = true,$;

 //THE VALUES USED IN YOUR TESTS WILL APPEAR IN THE
 PAGE...
   document.getElementById( test1 ).innerHTML =
 Regular
   Expression
 1: span class='regexp' + re1 + /span;
   document.getElementById( test2 ).innerHTML =
 Regular
   Expression
 1: span class='regexp' + re2 + /span;
   document.getElementById( testValue ).innerHTML
 = Test
   Value:
 span class='testval' + str + /span;

   if ( ( resultArray = re1.exec( str ) ) != null )
   {
 alert( Test 1 successful );
 if ( re2.test( resultArray[ 1 ] ) )
 {
 alert( Test 2 successful );
 }
 else
 {
 alert( Test 2 failed );
 }
   }
 /script
 /div
 /body
 /html

 ---

 ?xml version=1.0?
 !-- wrapper/GetURLInfo.mxml --
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 creationComplete=runRegExpTest( event )
 mx:Script
 ![CDATA[
 import mx.events.FlexEvent;
 import mx.controls.Alert;

 [Bindable] private var _test1:String = ;
 [Bindable] private var _test2:String = ;
 [Bindable] private var _testValue:String = ;

 private function runRegExpTest( e:FlexEvent ):void
 {
   var isTrue:RegExp =/^true\b(.*)$/;
   var isCurrency:RegExp =/^, ?\$/;
   var qualifier:String = TRUE;
   _test1 = isTrue.toString();
   _test2 = 

RE: [flexcoders] Re: Why Doesn't This JavaScript Regular Expression Work in AS3?

2008-08-11 Thread Gordon Smith
I believe the intention of the Player team was for AS3's RegExp class to
implement the Ecmascript-262 spec. If it's not in compliance, it would
be good to file a bug.

 

Gordon Smith

Adobe Flex SDK Team

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Josh McDonald
Sent: Monday, August 11, 2008 5:26 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Why Doesn't This JavaScript Regular
Expression Work in AS3?

 

I don't really do much JS these days (yay!), but Flash's regex is pretty
close to the standard, but you've just gotta get your head in and out
of regex space and think of things like the beginning and end of the
string, as well as what you're trying to test, and what you're trying to
match, etc.

Plus, I think JS has /g set by default, Flash doesn't. But that might be
wrong :)

-J

On Tue, Aug 12, 2008 at 3:56 AM, jwebbsuccess
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  wrote:

Josh,

You're pretty awesome off the top of your head.  Your change works.
Thanks a bunch.

Do you have a general statement about the difference between JS and
AS3 regular expressions by chance?



--- In flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com ,
Josh McDonald [EMAIL PROTECTED] wrote:

 Off the top of my head:

 var regex = /^true,\s*\$/;

 result = regex.test(str);


 On Mon, Aug 11, 2008 at 3:54 AM, jwebbsuccess [EMAIL PROTECTED]wrote:


  Exactly, haykelbj.  What I need help with is rewriting the regular
  expression for the isCurrency test so that the strings true,$ or
  true, $ will return true in AS3.  I'm not so hot at writing
  regexps...  isCurrency returns true on those two strings in
  JavaScript; I don't know why they return false in AS3.
 
 
 
  --- In flexcoders@yahoogroups.com
mailto:flexcoders@yahoogroups.com , haykelbj haykelbj@ wrote:
  
   The JavaScript and ActionScript codes are not doing exactly the
same
   thing. In your AS code, at a certain point you are doing the
following
   assignment:
   _testValue = qualifier.toLowerCase()+ ,$;
   This will result in _testValue = true,$ which will make the test
   isCurrency.test(_testValue) return false which is right because
   isCurrency's regex is /^, ?\$/.
  
  
   --- In flexcoders@yahoogroups.com
mailto:flexcoders@yahoogroups.com , jwebbsuccess jwebb@ wrote:
   
I have a regular expression that works in JavaScript and does
not work
in ActionScript 3, even though both languages supposedly use the
ECMAScript standard for regular expressions.  I need the
expression to
return true when ever it tests the two strings below:
   
true,$
true, $
   
I need the expression to return false whenever the string is
not the
same as one of the two above.
   
I've attached the HTML that demonstrates that the regular
expressions
work in JavaScript.  Can you modify the same expressions in
the Flex
code, provided below, to produce the same result?
   
Thanks.
   
---
html
head
style type=text/css
#doc {background-color:#EFEFEF;text-align:center;}
#testBlock
   
  
 
{background-color:#FF;text-align:left;width:600px;height:500px;margi
n:
0 auto;border:1px solid #FF9900;padding:0 20px;}
.regexp {color:#FF;}
.testval {color:#00CC00;}
/style
/head
body id=doc
div id=testBlock
  h1 id=test1/h1
  h1 id=test2/h1
  h1 id=testValue/h1
  pThe only two true values should be true,$ and true, $;
everything else should be false./p
  script type=text/javascript
   
//TEST YOUR REGULAR EXPRESSIONS HERE.
  var re1 = /^true\b(.*)$/;
  var re2 = /^, ?\$/;
  var str = true,$;
   
//THE VALUES USED IN YOUR TESTS WILL APPEAR IN THE
PAGE...
  document.getElementById( test1 ).innerHTML =
Regular
  Expression
1: span class='regexp' + re1 + /span;
  document.getElementById( test2 ).innerHTML =
Regular
  Expression
1: span class='regexp' + re2 + /span;
  document.getElementById( testValue ).innerHTML
= Test
  Value:
span class='testval' + str + /span;
   
  if ( ( resultArray = re1.exec( str ) ) != null )
  {
alert( Test 1 successful );
if ( re2.test( resultArray[ 1 ] ) )
{
alert( Test 2 successful );
}
else
{
alert( Test 2 failed );
}
  }
/script
/div
/body
/html
   
---
   
?xml version=1.0?
!-- wrapper/GetURLInfo.mxml --
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
http://www.adobe.com/2006/mxml

Re: [flexcoders] Re: Why Doesn't This JavaScript Regular Expression Work in AS3?

2008-08-11 Thread Josh McDonald
I think in any instance I've seen Flash not doing what I first expected
(with regexes at least), it was doing the right thing :)

-Josh

On Tue, Aug 12, 2008 at 10:48 AM, Gordon Smith [EMAIL PROTECTED] wrote:

  I believe the intention of the Player team was for AS3's RegExp class to
 implement the Ecmascript-262 spec. If it's not in compliance, it would be
 good to file a bug.



 Gordon Smith

 Adobe Flex SDK Team




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


[flexcoders] Re: Why Doesn't This JavaScript Regular Expression Work in AS3?

2008-08-10 Thread jwebbsuccess
Exactly, haykelbj.  What I need help with is rewriting the regular
expression for the isCurrency test so that the strings true,$ or
true, $ will return true in AS3.  I'm not so hot at writing
regexps...  isCurrency returns true on those two strings in
JavaScript; I don't know why they return false in AS3.



--- In flexcoders@yahoogroups.com, haykelbj [EMAIL PROTECTED] wrote:

 The JavaScript and ActionScript codes are not doing exactly the same
 thing. In your AS code, at a certain point you are doing the following
 assignment:
 _testValue = qualifier.toLowerCase()+ ,$;
 This will result in _testValue = true,$ which will make the test
 isCurrency.test(_testValue) return false which is right because
 isCurrency's regex is /^, ?\$/.
 
 
 --- In flexcoders@yahoogroups.com, jwebbsuccess jwebb@ wrote:
 
  I have a regular expression that works in JavaScript and does not work
  in ActionScript 3, even though both languages supposedly use the
  ECMAScript standard for regular expressions.  I need the expression to
  return true when ever it tests the two strings below:
  
  true,$
  true, $
  
  I need the expression to return false whenever the string is not the
  same as one of the two above.
  
  I've attached the HTML that demonstrates that the regular expressions
  work in JavaScript.  Can you modify the same expressions in the Flex
  code, provided below, to produce the same result?
  
  Thanks.
  
  ---
  html
  head
  style type=text/css
  #doc {background-color:#EFEFEF;text-align:center;}
  #testBlock
 

{background-color:#FF;text-align:left;width:600px;height:500px;margin:
  0 auto;border:1px solid #FF9900;padding:0 20px;}
  .regexp {color:#FF;}
  .testval {color:#00CC00;}
  /style
  /head
  body id=doc
  div id=testBlock
h1 id=test1/h1
h1 id=test2/h1
h1 id=testValue/h1
pThe only two true values should be true,$ and true, $;
  everything else should be false./p
script type=text/javascript
  
  //TEST YOUR REGULAR EXPRESSIONS HERE.
var re1 = /^true\b(.*)$/;
var re2 = /^, ?\$/;
var str = true,$; 
   
  //THE VALUES USED IN YOUR TESTS WILL APPEAR IN THE PAGE...
document.getElementById( test1 ).innerHTML = Regular 
  Expression
  1: span class='regexp' + re1 + /span;
document.getElementById( test2 ).innerHTML = Regular 
  Expression
  1: span class='regexp' + re2 + /span;
document.getElementById( testValue ).innerHTML = Test 
  Value:
  span class='testval' + str + /span;

if ( ( resultArray = re1.exec( str ) ) != null )
{
  alert( Test 1 successful );
  if ( re2.test( resultArray[ 1 ] ) )
  {
  alert( Test 2 successful );
  }
  else
  {
  alert( Test 2 failed );   
  }
}
  /script
  /div
  /body
  /html
  
  ---
  
  ?xml version=1.0?
  !-- wrapper/GetURLInfo.mxml --
  mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
  creationComplete=runRegExpTest( event )
  mx:Script
  ![CDATA[
  import mx.events.FlexEvent;
  import mx.controls.Alert;
  
  [Bindable] private var _test1:String = ;
  [Bindable] private var _test2:String = ;
  [Bindable] private var _testValue:String = ;
  
  private function runRegExpTest( e:FlexEvent ):void
  {
var isTrue:RegExp =/^true\b(.*)$/;
var isCurrency:RegExp =/^, ?\$/;
var qualifier:String = TRUE;
_test1 = isTrue.toString();
_test2 = isCurrency.toString();
var msg1:String;
var msg2:String;

if ( isTrue.test( qualifier.toLowerCase() ) )
{  
  _testValue = qualifier.toLowerCase()+ ,$;
  msg1 = The qualifier is:  + qualifier.toLowerCase() + ,
  the test value is (  + _testValue +  ) and returns:  +
  isCurrency.test( _testValue ).toString();
  trace( msg1 );
  Alert.show( msg1 );
  if ( isCurrency.test( _testValue ) )
  {
msg2 = The test is SUCCESSFUL!;
trace( msg2 );
Alert.show( msg2 );
  }
  else
  {
msg2 = The 'isCurrency' RegExp is UNSUCCESSFUL;
trace( msg2 );
Alert.show( msg2 );
  }
}
  }
  ]]
  /mx:Script
  mx:Form color=#FCFCFC cornerRadius=10 borderStyle=outset
  backgroundColor=#FAF7F7
mx:FormItem label='isTrue' regular expression test: 
  fontSize=18 color=#00
  mx:Label text={ _test1 } fontSize=18 color=#BF5100
  fontWeight=bold/
/mx:FormItem

Re: [flexcoders] Re: Why Doesn't This JavaScript Regular Expression Work in AS3?

2008-08-10 Thread Josh McDonald
Off the top of my head:

var regex = /^true,\s*\$/;

result = regex.test(str);

On Mon, Aug 11, 2008 at 3:54 AM, jwebbsuccess [EMAIL PROTECTED]wrote:

 Exactly, haykelbj.  What I need help with is rewriting the regular
 expression for the isCurrency test so that the strings true,$ or
 true, $ will return true in AS3.  I'm not so hot at writing
 regexps...  isCurrency returns true on those two strings in
 JavaScript; I don't know why they return false in AS3.



 --- In flexcoders@yahoogroups.com, haykelbj [EMAIL PROTECTED] wrote:
 
  The JavaScript and ActionScript codes are not doing exactly the same
  thing. In your AS code, at a certain point you are doing the following
  assignment:
  _testValue = qualifier.toLowerCase()+ ,$;
  This will result in _testValue = true,$ which will make the test
  isCurrency.test(_testValue) return false which is right because
  isCurrency's regex is /^, ?\$/.
 
 
  --- In flexcoders@yahoogroups.com, jwebbsuccess jwebb@ wrote:
  
   I have a regular expression that works in JavaScript and does not work
   in ActionScript 3, even though both languages supposedly use the
   ECMAScript standard for regular expressions.  I need the expression to
   return true when ever it tests the two strings below:
  
   true,$
   true, $
  
   I need the expression to return false whenever the string is not the
   same as one of the two above.
  
   I've attached the HTML that demonstrates that the regular expressions
   work in JavaScript.  Can you modify the same expressions in the Flex
   code, provided below, to produce the same result?
  
   Thanks.
  
   ---
   html
   head
   style type=text/css
   #doc {background-color:#EFEFEF;text-align:center;}
   #testBlock
  
 
 {background-color:#FF;text-align:left;width:600px;height:500px;margin:
   0 auto;border:1px solid #FF9900;padding:0 20px;}
   .regexp {color:#FF;}
   .testval {color:#00CC00;}
   /style
   /head
   body id=doc
   div id=testBlock
 h1 id=test1/h1
 h1 id=test2/h1
 h1 id=testValue/h1
 pThe only two true values should be true,$ and true, $;
   everything else should be false./p
 script type=text/javascript
  
   //TEST YOUR REGULAR EXPRESSIONS HERE.
 var re1 = /^true\b(.*)$/;
 var re2 = /^, ?\$/;
 var str = true,$;
  
   //THE VALUES USED IN YOUR TESTS WILL APPEAR IN THE PAGE...
 document.getElementById( test1 ).innerHTML = Regular
 Expression
   1: span class='regexp' + re1 + /span;
 document.getElementById( test2 ).innerHTML = Regular
 Expression
   1: span class='regexp' + re2 + /span;
 document.getElementById( testValue ).innerHTML = Test
 Value:
   span class='testval' + str + /span;
  
 if ( ( resultArray = re1.exec( str ) ) != null )
 {
   alert( Test 1 successful );
   if ( re2.test( resultArray[ 1 ] ) )
   {
   alert( Test 2 successful );
   }
   else
   {
   alert( Test 2 failed );
   }
 }
   /script
   /div
   /body
   /html
  
   ---
  
   ?xml version=1.0?
   !-- wrapper/GetURLInfo.mxml --
   mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
   creationComplete=runRegExpTest( event )
   mx:Script
   ![CDATA[
   import mx.events.FlexEvent;
   import mx.controls.Alert;
  
   [Bindable] private var _test1:String = ;
   [Bindable] private var _test2:String = ;
   [Bindable] private var _testValue:String = ;
  
   private function runRegExpTest( e:FlexEvent ):void
   {
 var isTrue:RegExp =/^true\b(.*)$/;
 var isCurrency:RegExp =/^, ?\$/;
 var qualifier:String = TRUE;
 _test1 = isTrue.toString();
 _test2 = isCurrency.toString();
 var msg1:String;
 var msg2:String;
  
 if ( isTrue.test( qualifier.toLowerCase() ) )
 {
   _testValue = qualifier.toLowerCase()+ ,$;
   msg1 = The qualifier is:  + qualifier.toLowerCase() + ,
   the test value is (  + _testValue +  ) and returns:  +
   isCurrency.test( _testValue ).toString();
   trace( msg1 );
   Alert.show( msg1 );
   if ( isCurrency.test( _testValue ) )
   {
 msg2 = The test is SUCCESSFUL!;
 trace( msg2 );
 Alert.show( msg2 );
   }
   else
   {
 msg2 = The 'isCurrency' RegExp is UNSUCCESSFUL;
 trace( msg2 );
 Alert.show( msg2 );
   }
 }
   }
   ]]
   /mx:Script
   mx:Form color=#FCFCFC cornerRadius=10 borderStyle=outset
   backgroundColor=#FAF7F7
 

[flexcoders] Re: Why Doesn't This JavaScript Regular Expression Work in AS3?

2008-08-08 Thread haykelbj
The JavaScript and ActionScript codes are not doing exactly the same
thing. In your AS code, at a certain point you are doing the following
assignment:
_testValue = qualifier.toLowerCase()+ ,$;
This will result in _testValue = true,$ which will make the test
isCurrency.test(_testValue) return false which is right because
isCurrency's regex is /^, ?\$/.


--- In flexcoders@yahoogroups.com, jwebbsuccess [EMAIL PROTECTED] wrote:

 I have a regular expression that works in JavaScript and does not work
 in ActionScript 3, even though both languages supposedly use the
 ECMAScript standard for regular expressions.  I need the expression to
 return true when ever it tests the two strings below:
 
 true,$
 true, $
 
 I need the expression to return false whenever the string is not the
 same as one of the two above.
 
 I've attached the HTML that demonstrates that the regular expressions
 work in JavaScript.  Can you modify the same expressions in the Flex
 code, provided below, to produce the same result?
 
 Thanks.
 
 ---
 html
 head
 style type=text/css
 #doc {background-color:#EFEFEF;text-align:center;}
 #testBlock

{background-color:#FF;text-align:left;width:600px;height:500px;margin:
 0 auto;border:1px solid #FF9900;padding:0 20px;}
 .regexp {color:#FF;}
 .testval {color:#00CC00;}
 /style
 /head
 body id=doc
 div id=testBlock
   h1 id=test1/h1
   h1 id=test2/h1
   h1 id=testValue/h1
   pThe only two true values should be true,$ and true, $;
 everything else should be false./p
   script type=text/javascript
   
   //TEST YOUR REGULAR EXPRESSIONS HERE.
 var re1 = /^true\b(.*)$/;
 var re2 = /^, ?\$/;
 var str = true,$; 
  
   //THE VALUES USED IN YOUR TESTS WILL APPEAR IN THE PAGE...
 document.getElementById( test1 ).innerHTML = Regular 
 Expression
 1: span class='regexp' + re1 + /span;
 document.getElementById( test2 ).innerHTML = Regular 
 Expression
 1: span class='regexp' + re2 + /span;
 document.getElementById( testValue ).innerHTML = Test 
 Value:
 span class='testval' + str + /span;
 
 if ( ( resultArray = re1.exec( str ) ) != null )
 {
   alert( Test 1 successful );
   if ( re2.test( resultArray[ 1 ] ) )
   {
   alert( Test 2 successful );
   }
   else
   {
   alert( Test 2 failed );   
   }
 }
   /script
 /div
 /body
 /html
 
 ---
 
 ?xml version=1.0?
 !-- wrapper/GetURLInfo.mxml --
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
 creationComplete=runRegExpTest( event )
 mx:Script
 ![CDATA[
 import mx.events.FlexEvent;
 import mx.controls.Alert;
 
 [Bindable] private var _test1:String = ;
 [Bindable] private var _test2:String = ;
 [Bindable] private var _testValue:String = ;
 
 private function runRegExpTest( e:FlexEvent ):void
 {
   var isTrue:RegExp =/^true\b(.*)$/;
   var isCurrency:RegExp =/^, ?\$/;
   var qualifier:String = TRUE;
   _test1 = isTrue.toString();
   _test2 = isCurrency.toString();
   var msg1:String;
   var msg2:String;
   
   if ( isTrue.test( qualifier.toLowerCase() ) )
   {  
 _testValue = qualifier.toLowerCase()+ ,$;
 msg1 = The qualifier is:  + qualifier.toLowerCase() + ,
 the test value is (  + _testValue +  ) and returns:  +
 isCurrency.test( _testValue ).toString();
 trace( msg1 );
 Alert.show( msg1 );
 if ( isCurrency.test( _testValue ) )
 {
   msg2 = The test is SUCCESSFUL!;
   trace( msg2 );
   Alert.show( msg2 );
 }
 else
 {
   msg2 = The 'isCurrency' RegExp is UNSUCCESSFUL;
   trace( msg2 );
   Alert.show( msg2 );
 }
   }
 }
 ]]
 /mx:Script
 mx:Form color=#FCFCFC cornerRadius=10 borderStyle=outset
 backgroundColor=#FAF7F7
   mx:FormItem label='isTrue' regular expression test: 
 fontSize=18 color=#00
 mx:Label text={ _test1 } fontSize=18 color=#BF5100
 fontWeight=bold/
   /mx:FormItem
   mx:FormItem label='isCurrency' regular expression test:
 fontSize=18 color=#00
 mx:Label text={ _test2 } fontSize=18 color=#BF5100
 fontWeight=bold/
   /mx:FormItem
   mx:FormItem label='test value is:  fontSize=18
color=#00
 mx:Label text={ _testValue } fontSize=18
 color=#BF5100 fontWeight=bold/
   /mx:FormItem
 /mx:Form
 /mx:Application