Skip to main content
Inspiring
September 20, 2007
Question

Need help in RegExp AS 3.0

  • September 20, 2007
  • 2 replies
  • 329 views
Hi,

var str:String ="123+31+21-25*5";
var re:RegExp = /(\d+)/;
var results:Array = str.split(re);
trace(results)
// ,123,+,31,+,21,-,25,*,5,*/

//but if the string will be is ...
var str:String ="123.5+31.5+21-25*5";
var re:RegExp = /(\d+)/;
var results:Array = str.split(re);
trace(results)
//,123,.,5,+,31,.,5,+,21,-,25,*,5,

but i need to split like 123.5,+,31.5,-,21,5,*,5
Actually i do't want to split the Dot(.)... bcoz i need to some Math Calcilation According to the user inputs
Can any one help me for this issu
This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
September 21, 2007
you're welcome.

regular expressions (using the same metacharacters and characters) are used in many computer languages. you could use google to search for a regular expression tutorial.

here's one for the python language, but as i mentioned, it's valid for actionscipt's verions, too:

http://www.amk.ca/python/howto/regex/

kglad
Community Expert
Community Expert
September 20, 2007
try:

AScrackerAuthor
Inspiring
September 21, 2007
Thanks kglad
it's working fine ...
but i do't know what the actually is going on "var re:RegExp = /(\d+\.*\d*)/;"
please can u explain this code... hw it's running

kglad
Community Expert
Community Expert
September 21, 2007
: