fjord/main.rb

19 lines
315 B
Ruby
Raw Normal View History

2024-03-29 22:34:24 +09:00
print 'Text?: '
text = gets.chomp
begin
print 'Pattern?: '
pattern = gets.chomp
regexp = Regexp.new(pattern)
rescue RegexpError => e
puts "Invalid pattern: #{e.message}"
retry
end
matches = text.scan(regexp)
if matches.size > 0
puts "Matched: #{matches.join(', ')}"
else
puts 'Nothing matched.'
2024-03-16 22:40:05 +09:00
end