Index: /CKEditor/branches/prototype/_source/core/tools.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/tools.js	(revision 2346)
+++ /CKEditor/branches/prototype/_source/core/tools.js	(revision 2347)
@@ -300,5 +300,5 @@
 	{
 		// We are not using \s because we don't want "non-breaking spaces" to be caught.
-		var trimRegex = /(?:^[ \t\n\r]+)/g;
+		var trimRegex = /^[ \t\n\r]+/g;
 		return function( str )
 		{
@@ -318,5 +318,5 @@
 	{
 		// We are not using \s because we don't want "non-breaking spaces" to be caught.
-		var trimRegex = /(?:[ \t\n\r]+$)/g;
+		var trimRegex = /[ \t\n\r]+$/g;
 		return function( str )
 		{
Index: /CKEditor/branches/prototype/_source/tests/core/tools.html
===================================================================
--- /CKEditor/branches/prototype/_source/tests/core/tools.html	(revision 2346)
+++ /CKEditor/branches/prototype/_source/tests/core/tools.html	(revision 2347)
@@ -110,4 +110,34 @@
 			assert.areSame( number +  3, CKEDITOR.tools.getNextNumber() );
 		},
+		
+		test_trim1 : function()
+		{
+			assert.areSame( 'test', CKEDITOR.tools.trim( '    test   ' ) );
+		},
+
+		test_trim2 : function()
+		{
+			assert.areSame( 'test', CKEDITOR.tools.trim( ' \n \t  test\n  \t ' ) );
+		},
+
+		test_ltrim1 : function()
+		{
+			assert.areSame( 'test   ', CKEDITOR.tools.ltrim( '    test   ' ) );
+		},
+
+		test_ltrim2 : function()
+		{
+			assert.areSame( 'test\n  \t ', CKEDITOR.tools.ltrim( ' \n \t  test\n  \t ' ) );
+		},
+
+		test_rtrim1 : function()
+		{
+			assert.areSame( '    test', CKEDITOR.tools.rtrim( '    test   ' ) );
+		},
+
+		test_rtrim2 : function()
+		{
+			assert.areSame( ' \n \t  test', CKEDITOR.tools.rtrim( ' \n \t  test\n  \t ' ) );
+		},
 
 		name : document.title
