How can I express \"not preceded by\" in a Java regular expression? For example I would like to search for \":\" but only when it is not directly preceded by \"\\\". How c
Use a negative lookbehind:
"(?
The reason for the four backslashes is:
\\
to match a single backslash.\\
, giving a total of four.Example code:
Pattern pattern = Pattern.compile("(?
Output:
10