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
Did you try using a character class with the complement operator?
String s1 = "foo : bar";
String s2 = "foo \\: bar";
Pattern p = Pattern.compile("[^\\\\]:");
Matcher m = p.matcher(s1);
if(m.find()) {
System.out.println(m.group());
}
m = p.matcher(s2);
if(m.find()) {
System.out.println(m.group());
}