Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am trying to detect spaces on textarea my code is following
textarea.value.replace(/\s/g, ' ');
but it detects all whitespaces and I want to detect only spaces...
is any solution??
/ /g
/\u0020/g
textarea.value.replace(/ /g, ' '); // that's a space ------^
Add a comment
use a literal space, like so:
textarea.value.replace(/ /g, ' ');
Use this:
textarea.value.replace(/[ ]/g, ' ');
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
/ /gmaybe? Should work./\u0020/g