Fonction PHP trim() en JavaScript (prototype, function)
14`01`2008
Aucun commentaire • Poster un commentaire !
Tags: Javascript PHP
String.prototype.trim = function() {
return this.replace(/^\s*|\s*$/g, '');
};
Exemple
var v_string = ' Hello World ! ';
document.writeln('"' + v_string.trim() + '"'); // "Hello World !"