String.match returns a MatchData, but how can I get the matched string from MatchData?
puts "foo bar".match(/(foo)/)
output:
#<MatchData "foo" 1:"foo">
Sorry I am new to crystal.
String.match returns a MatchData, but how can I get the matched string from MatchData?
puts "foo bar".match(/(foo)/)
output:
#<MatchData "foo" 1:"foo">
Sorry I am new to crystal.
You can access it via the well known group indexes, make sure to handle the nil (no match) case.
You can find more information about
MatchDatain its API docs