Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
コードが続いているテキストエリアのスペースを検出しようとしています
textarea.value.replace(/\s/g, ' ');
しかし、それはすべての空白を検出し、スペースのみを検出したい...
解決策はありますか??
textarea.value.replace(/ /g, ' '); // that's a space ------^
次のように、リテラル スペースを使用します。
textarea.value.replace(/ /g, ' ');
これを使って:
textarea.value.replace(/[ ]/g, ' ');