Hi!

Based on the test program for regular expressions in the Ruby User's Guide I
wanted to change it somewhat.

st = "\033[7m"
en = "\033[m"
while TRUE
  print "str> "
  STDOUT.flush
  str = gets
  break if not str
  str.chop!
  print "pat> "
  STDOUT.flush
  re = gets
  break if not re
  re.chop!
  str.gsub! re, "#{st}\\&#{en}"
  print str, "\n"
end
print "\n"

str.gsub! re, "#{st}\\&#{en}"

I want to change the above line to some code that executes a regex pattern
for a string and then to be able to extract the number of matches and the
matching strings. I've looked att $~ but I can't get it to work.

Best regards

Robert