Index: core.js
===================================================================
--- core.js	(revision 4789)
+++ core.js	(working copy)
@@ -1114,7 +1114,11 @@
 	},
 	
 	trim: function( text ) {
-		return (text || "").replace( /^\s+|\s+$/g, "" );
+		var text = (text || "").replace(/^\s\s*/, ''),
+		    ws = /\s/,
+		    i = text.length;
+		while ( ws.test(text.charAt(--i)) );
+		return text.slice(0, i + 1);
 	},
 
 	makeArray: function( array ) {

