2017-02-21 98 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

相關問題