Extract number from string in Ruby
Posted
by Oscar Reyes
on Stack Overflow
See other posts from Stack Overflow
or by Oscar Reyes
Published on 2010-04-14T20:31:30Z
Indexed on
2010/04/14
20:33 UTC
Read the original article
Hit count: 211
I'm using this code:
s = line.match( /ABCD(\d{4})/ ).values_at( 1 )[0]
To extract numbers from strings like:
ABCD1234
ABCD1235
ABCD1236
etc.
It works, but I wonder what other alternative I have to to this in Ruby?
© Stack Overflow or respective owner