programming-examples/js/Vre1/Alternet of trim function( ) using regular expression.js
2019-11-15 12:59:38 +01:00

15 lines
249 B
JavaScript

function Trim(str)
{
var result;
if (typeof str === 'string')
{
result = str.replace(/^\s+|\s+$/g, '');
return result;
}
else
{
return false;
}
}
console.log(Trim(' w3resource '));