R
R
Ratibor Shugaev2021-06-27 23:21:16
Regular Expressions
Ratibor Shugaev, 2021-06-27 23:21:16

Regular expression to replace character between digit and digit?

Good day. Skills in the compilation of regular seasons are not yet enough, so I decided to ask for help. For example, we have a string:
text=smth?text2=100&numbers0&1some_words_and_else_numbers=[2&3]

How can we compose a regular expression so that all parts of a string like [0&1] or 0&1 are replaced by [0,1] or 0,1. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-06-27
@ratibordas

.replace(/(\d)&(\d)/g, '$1,$2')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question