D
D
Dmitry Markov2021-11-19 15:59:15
JavaScript
Dmitry Markov, 2021-11-19 15:59:15

How to fix regex to work in ios?

Source line:

"<p>&nbsp;СЛОВО&nbsp;СЛОВО&nbsp;СЛОВО&nbsp;</p><p>&nbsp; &nbsp;СЛОВО&nbsp;СЛОВО&nbsp;СЛОВО&nbsp; &nbsp;</p>"

Desired result:
"<p>СЛОВО&nbsp;СЛОВО&nbsp;СЛОВО</p><p>СЛОВО&nbsp;СЛОВО&nbsp;СЛОВО</p>"


There is a working regex regex:
str.replace(/(?<=>)(?:&nbsp;| )+|(?:&nbsp;| )+(?=<)/gim, '')

The problem is that on ios I get an "invalid group specifier name" error. How to fix regex to work on ios?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-11-19
@dodo512

str.replace(/(>)(?:&nbsp;| )+|(?:&nbsp;| )+(?=<)/gim, '$1')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question