Your requirements are ambiguous. Do you want to delete spaces from the end ("I want to delete all the spaces at the end of each element.") or do you want to delete all spaces ("The element should only consist of characters, no spaces at all.")? If the former, then substitution with s/// (as shown by hdb) is a good option; if the latter, then transliteration with y/// might be better.

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other