def show_regexp(a, re)
if a =~ re
"#{$`}<<#{$&}>>#{$'}"
else
"no match"
end
end
# match duplicated letter
show_regexp('He said "Hello"', /(\w)\1/) # He said "He<>o"
# match duplicated substrings
show_regexp('Mississippi', /(\w+)\1/) # M<>ippi