[note to self]
For a given string that contains one or more grouping of digits, extract the last grouping of digits.
var s:String = "blah blah 123 blah 456 today is Blah 24 2011"; var desiredOutput:String = "2011";
var s:String = "custom label 24"; var i:int = s.search( /(\d)+$/ ); var output:String = s.substring( i ); trace( output ); //"24"
Given the following regexp:
- (\d) – digits grouping
- + – greedy match, meaning try to group as many digits as possible before satisfying the group matching
- $ – start at the end of the string
Notice I did not use the global flag g at the end of the regexp.