I think if you can use SQL Server 2017, this new function Trim() Can help you write it better. if you insist on using DQS for this matter, I think this article can help you find your way. Sorry that I couldn't write it for you. Hope it helps.

Only top voted, non community-wiki answers of a minimum length are eligible