in reply to Quick Question about checking what the regex does

"Hello, can someone help me write a code that shows what words the regex actually matches?"

You can add the following line to your existing code to achieve this:

use Regexp::Debugger;

See Regexp::Debugger.

-- Ken