I have an input, which can have different structure. I would like to test few patterns and get corresponding matching parts in each case without repeating the regular expressions. For example:
a = "hello123"
case a
when /^([0-9]+)([a-z]+)$/
# how to get matching values?
when /^([a-z]+)([0-9]+)$/
# how to get matching values?
else
end
It is a very simple example, and my code is a bit more complex.