I am trying to construct a regex to check if a letter occurs in a string, it should be precede only one of 2 other characters. I can do this for one set of chars, but how do I do it for multiple sets in a string?
For example: C can only precede A or B, i.e. if C is found the next char can only be A or B. F can only precede D or E (F cannot precede A or B)
A or B, then C can occur D or E, then F can occur
How do I do this?
The following gives me an error:
String pattern = "([F][D|E])|([A][B|C])";
String test = "FEAC";
System.out.println(test.matches(pattern));