I have a long string formatted like a log entry and am looking to get several captures from it and store them in different variables.
I know Ruby stores the first 9 captures into the variables $1...$9, does it also store other captures in $10...$99?
If not what would be a simple way to do this?
String#match
returns MatchData
object which holds an array of captures.
m = Regexp.new('(.)' * 20).match('The quick brown fox jumps over the lazy dog')
m[12]
# => "r"
Although $12 also works:
> $12
# => "r"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With