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?
My code:
ids = []
someBigString.lines.each {|line|
ids << line.match( /ABCD(d{4})/ ).values_at( 1 )[0]
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…