正規表現 空白以外の文字にマッチする「\S」
記事作成日: 2022-02-21
空白以外の文字にマッチします。[^ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff] に相当します。
使用例
console.log('1 2\t3'.match(/\S/)) // Array [ "1" ]
console.log('1 2\t3'.match(/\S/g)) // Array(3) [ "1", "2", "3" ]
console.log('1 2\t34'.match(/\S\S/)) // Array [ "34" ]
マッチしない例
console.log('1 2\t\t3'.match(/\S\S/g)) // null