in reply to what regular expression do I need?

Look at the documentation for perlre, chomp, and perlretut. Others have given you actual solutions to your (very homeworkish) question.

--MidLifeXis