Fixing "sed: RE error: illegal byte sequence"

Hello,

I was getting the error `sed: RE error: illegal byte sequence` on my Mac. After some debugging and a few Google searches, I came up with this solution.

Please, let me know if you want me to make any change to the code.

Ciao
Daniele