DOH!
I got so fixated on solving it through Regex I completely ignored the simple solution of using trim(). It does indeed work perfectly.
Many thanks for pointing out the obvious!
Do I at least get a wry smile for including references to 3rd Rock from the Sun and The Simpsons?