C
C
ch-aqwer2018-02-23 18:14:23
JavaScript
ch-aqwer, 2018-02-23 18:14:23

How to replace multiple spaces with a single character with a regular expression?

How to add a regular expression so that it does such a "walk-some" from such a "walk_______some "line ?
That is, it replaced all spaces with one character.
_______ are spaces)
Stopped at this
str.replace(/\s/g, '-');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-02-23
@ch-aqwer

str.replace(/\s+/g, '-')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question