M
M
Michael2021-09-19 16:29:55
JavaScript
Michael, 2021-09-19 16:29:55

Regex: how to remove all spaces only between words?

Spaces at the beginning and end should remain, you need to remove only between words.
For example:
" Some text "must return " Sometext "
"two words"return"twowords"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-09-19
@Misha5

str.replace(/(?<=\S)\s+(?=\S)/g, '')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question