Reg Exp help

classic Classic list List threaded Threaded
3 messages Options
jfb
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Reg Exp help

jfb
Hi All,
I am trying to replace all commas with nothing from a string.
var cText:String = "36,000,000";
var regEx:RegExp = /,/g;
cText = cText.replace(regEx,"");

The result for cText is 36000,000.
It is only replacing the first comma. Why the global (g) option is not working?
Thanks !
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg Exp help

kamcknig
That's strange, I copied and pasted your code into FlashDevelop and ran it
and traced out cText and it came out properly to "36000000"


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Tue, Jul 25, 2017 at 10:16 AM, jfb <[hidden email]> wrote:

> Hi All,
> I am trying to replace all commas with nothing from a string.
> var cText:String = "36,000,000";
> var regEx:RegExp = /,/g;
> cText = cText.replace(regEx,"");
>
> The result for cText is 36000,000.
> It is only replacing the first comma. Why the global (g) option is not
> working?
> Thanks !
>
>
>
> --
> View this message in context: http://apache-flex-users.
> 2333346.n4.nabble.com/Reg-Exp-help-tp15486.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>
jfb
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg Exp help

jfb
Yes, I run just this code and it works.
It maybe something else in my component. Thanks for you reply and help!
Loading...