in reply to regexp: removing extra whitespace

Do you want all rules to be performed simultanuously? Or sequentially? That is, if I have "foo{space}{tab}{space}bar" should that result in "foo{space}{space}bar", or in "foo{space}bar"? Rule 2 says repeating spaces should be collapsed, but the original string doesn't have repeated spaces - they only repeat after rule 1 has been applied.

Assuming rules should be applied in order:

no warnings "uninitialized"; s/([ \n])|\s/$1/g; s/(\s)\K\1+//g;
If they apply all at once:
no warnings "uninitialized"; s/([ \n])\1+|\s/$1/g;
(None of the snippets above were tested).