摘要:javascript-trim
假設原本的字串為:
var txt = " hello! world~ ";
經過以下魔法:
var txt_trim = txt.replace( /^\s+|\s+$/g, "" );
結果:
txt_trim => "hello! world~"
太神奇啦~
摘要:javascript-trim
假設原本的字串為:
var txt = " hello! world~ ";
經過以下魔法:
var txt_trim = txt.replace( /^\s+|\s+$/g, "" );
結果:
txt_trim => "hello! world~"
太神奇啦~