programming-examples/js/Vre1/Alternet of trim function( ) using regular expression.js

15 lines
249 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function Trim(str)
{
var result;
if (typeof str === 'string')
{
result = str.replace(/^\s+|\s+$/g, '');
return result;
}
else
{
return false;
}
}
console.log(Trim(' w3resource '));