2017-02-21 101 views
-2

我有以下字符串:替换字符串双引号后引号

<something=""Some" random string" somethingelse="Another "random" string"> 

我需要将其更改为这个

<something="&quot;Some&quot; random string" somethingelse="Another &quot;random&quot; string"> 

基本上离开“外”引号和改变引号内他们&quot;

我认为一些正则表达式可能被用来做到这一点,但我不知道逻辑应该是什么。任何想法?

+0

所以你还没有尝试过任何yourseld,没有? – Fallenhero

+0

你应该[在这里看到答案](http://stackoverflow.com/questions/12290882/regex-to-escape-double-quotes-inside-double-quotes-with-preg-replace) –

+0

只是把“你想要你的报价或使用单引号。 – Kornflexx

回答

0

使用

echo '<something='.chr(34).'Some'.chr(34).' random string" somethingelse="Another "random" string">'; 

例如:

你可以试试这个:echo chr(34).'Some'.chr(34).' random string';

"Some" random string 

Ascii Table for Quotes and different elements

+1

你回答什么问题? – Toto

相关问题