A few notes on your code:
- In HTML, it's , and not you are missing the semicolons
- Your substitutions have unnecessary brackets. (\s{5}) will match the same as \s{5}. The difference is that the brackets will capture those spaces into $1, but you don't seem to need that here
- On the right hand side of substitutions, you don't need to escape the ampersand character
- On your subroutines (or code blocks, for that matter), try to indent things (not sure if you just missed that because of pasting the code here)
Hope you live a happier life because of this :-)