E
E
Evgenii Borovoi2021-11-12 16:53:42
PHP
Evgenii Borovoi, 2021-11-12 16:53:42

How to get around double quotes in tags with a regular expression or another way when passing through JSON?

I have a hell of a legacy. Lots of articles. Initially, the text of the articles is loaded from php immediately into html.
We are redoing it in a new way and with a separate request, via JSON.
The format naturally breaks on double quotes. If you replace all quotes with " , then links, or other possible tags that are in the text, will be broken. All I could think of was to catch tags on the server before output and replace " with ' in them. But I'm not strong in regular expressions, so I'm asking for help. Or maybe someone knows another way.
upd: json_encode does not work because of the old version from Russian encoding (1251)
Below is an example of a database field.

<p>В нашем городе закроют парковку. Как "<a href="https://www.somesite.ru">Наш сайт</a>" рассказали в администрации города, там начнут строить ледовый городок.</p>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question