I\'m using this code:
s = line.match( /ABCD(\\d{4})/ ).values_at( 1 )[0]
To extract numbers from strings like:
ABCD1234 AB
your_input = "abc1cd2" your_input.split(//).map {|x| x[/\d+/]}.compact.join("").to_i
This should work.