I was playing around with Regex in Java and I wanted to match a String which has 0 or 1 occurrence of a dot
X? X, once or not at all
String str = "abc.def";
The correct pattern is:
First any number of characters which are not a dot, then optionally one dot followed by any number of characters which are not a dot.