(u_u)

crystal入門:正規表現でマッチした文字列をすべて返す:[String] #scan(pattern : Regex)

Categories: [blog]
Tags: [crystal]

def scan(pattern : Regex)

Searches the string for instances of pattern, returning an Array of Regex::MatchData for each match.

match_data = "hello".scan(/he/)
match_data.each_index do |i|
    puts match_data[i][0]
end