In my program I will be reading a java file line by line, and if there is any string literal in that line, i will replace it with (say) \"ABC\".
Is there any
s = s.replaceAll("\"([^\n\"\\]+|\\\\.)*\"", "\"ABC\"");
This searches quote, and any either non-quotes/non-backslahes/non-linefeeds or backslash+character, till quote.
\"
(
[^\n\"\\]+
|
\\\\.
)*
\"
[^ ... ] non of the enclosed chars, range possible too A-Z.| or.. any character, by default not line endings.... + one or more of ... .... * zero or more of ... .