Now I have a String and I want to delete \n and convert \u to \\u.
If the String contains \\u,I will not change it to \\\u.
I want to use String.replaceAll(), but I don`t know how to write the regular expression.
please help me. thanks.
example:
\u => \\u
\\u => \\u (do nothing)
Here’s a solution using a negative look-behind. (Changes
\uto\\uonly if it is not preceeded by a\.)Prints:
\nremoved\uis changed to\\ubut while\\uis preserved as it is.