I'm trying to get a similar result \ has in Java String literals. If there are two of them, it's a \, otherwise it "escapes" whatever follows. So if there is a delimiter that follows a single release char, it doesn't count. But two release chars resolve to a release char literal, so then the following delimiter should be considered a delimiter. So, if an odd number of release chars precede a delimiter, it's ignored. For 0 or an even number it's a delimiter. So, in the code example below:
?: <- : is not a delimiter
??: <- : is a delimiter
???: <- : is not a delimiter
????: <- : is a delimiter
Here's sample code showing what doesn't work.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestPattern
{
public static void main(final String[] args)
{
final Matcher m = Pattern.compile("(\\?\\?)*[^\\?]\\:").matcher("a??:b:c");
m.find(0);
System.out.println(m.end());
}
}