If you can make sure that there are no nested parenthsis, you can do it in Regex. Otherwise you can not.
E.g. in C#:
string input = "Remove all spaces from this (Don't remove spaces from this) Again remove spaces";
string output = Regex.Replace(input, @"\s*(\(.*?\)|\S+)\s*", "$1");
Console.WriteLine(input);
Console.WriteLine(output);
This results in
Remove all spaces from this (Don't remove spaces from this) Again remove spaces
Removeallspacesfromthis(Don't remove spaces from this)Againremovespaces
Cheers
Andi