正则表达式怎么check出字符串的前后是否含有空格
例: test
test
1234
一定需要用正则表达式?
<script type="text/javascript">
function check(s) {
return /^\s+|\s+$/.test(s);
}
console.log(check("test test"));
console.log(check(" test test"));
console.log(check("test test "));
</script>