There are a few plugins that do this, depending on what you need to trim. HTML Strip comes to mind.
A plugin is definitely what you’re after.
They’re not hard to create - take a look at the developer documentation. The functionality you’re after already exists in the create_url_title function of the regex class (found in system/core/core.regex.php).
I’ll move it down to plugin development to get some more eyes on it.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.