# Everything within the group is treated as a single regular expression.
def show_regexp(a, re)
if a =~ re
"#{$`}<<#{$&}>>#{$'}"
else
"no match"
end
end
show_regexp('banana', /an*/) # b<>ana
show_regexp('banana', /(an)*/) # <<>>banana
show_regexp('banana', /(an)+/) # b<>a