N
N
Nikolay Semenov2018-04-04 11:12:14
JavaScript
Nikolay Semenov, 2018-04-04 11:12:14

How to replace every second or even space in a string with ";"?

Tell me how to solve the question in the title, what regular expression to use?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-04-04
@nickola105

'1 2 3 4 5 6 7 8 9 0'.replace(/([^ ]+ [^ ]+) /g, '$1;') // "1 2;3 4;5 6;7 8;9 0"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question