in reply to Line trimming regex doesn't work as expected

It's difficult to guess what the problem might be without some more information:

What is the input data?

What output are you expecting?

How is the code failing to do what you expect?