in reply to Print the matched pattern

A few points about your code.

I hope these points are helpful.

Cheers,

JohnGG