RE: javascript: trim?

From: Martin Svarovsky (martin.svarovsky@ileo.cz)
Date: 03. 02. 2003, 15:29 CET


> existuje v javascripte ekvivalent php funkcii trim() - teda 
> nieco na orezanie "white spaces" zo stringu
> 
Muzes na to jit bud smyckou nebo regularnimi vyrazy.
Zde je priklad funkce s reg. vyrazem:

function trim(string)
{
var re= /^\s*|\s*$/g;
return string.replace(re,"");
}

Tenhle kod je k nalezeni treba na 
http://p2p.wrox.com/archive/javascript/2002-05/3.asp
Varianta se smyckou (delsi, pomalejsi, ale srozumitelnejsi) je treba na 
http://www.vermontsoftware.com/Javascript/trim.html 

Martin



This archive was generated by hypermail 2.1.2 : 03. 02. 2003, 15:29 CET