How to escape the character \ in PHP and Javascript? -


I have this line of code and is causing the problem (at least in the highlighting of the excellent text. Can this escape?

  text = text.replace (": \", "lg; img src = 'picture / smileys_08.png' class = 'smiley' / & gt; ); Text = Text.replace (": - \", "& lt; img src = 'images / smilleys_08.png' class = 'smilley' / & gt;");  

  $ tempText = str_replace (": \", " "$ TempText); $ tempText = str_replace (": - \ "," & lt; img src = 'Picture / Smileys_08.png' class = 'smiley' / '', $ tempText); Like    

you avoid any other characters: a \ Add:

  text = text.replace (": \\", "& lt; img src = 'image / smileys_08.png' class = 'smiley' / & Gt; ");  

This is counted as both for php ja avaScript.

Task example:

  warning (": \\ bla bla: \\ test" .replace (": \\", "& lt; img src = '' Images / smileys_08.png 'class =' ​​smiley '/ & gt; ")); Just keep in mind that instead of a string, only the first occurrence of the search string changes as shown in the demo.  

To fix this, change this regex:

  alert (": \\ bla bla: \\ test" .replace (/: \\ / g , "& Lt; img src = 'images / smilleys_08.png' class = 'smiley' / & gt;"));  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -