Tuesday, 15 March 2011

Fastest trim in javascript

function trim(value) {var temp = value;var obj = /^(\s*)([\W\w]*)(\b\s*$)/;if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }var obj = / +/g;temp = temp.replace(obj, " ");if (temp == " ") { temp = ""; }return temp;}

How Do You Use This Function :
var a = trim(document.getElementById('TextBoxID').value);

No comments:

Post a Comment

Get all non-clustered indexes

DECLARE cIX CURSOR FOR     SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID         FROM Sys.Indexes SI             ...