Suppose I have a row in four connect where X is player 1, _ is an empty slot and O is player two. Te row looks like this
X_X_XXXO
I want to check for these patterns
String patternString = "XXX_|XX_X|X_XX|_XXX";
this returns only one match : X_XX but I also want _XXX to return;
How should I expand my patternstring?
thank you
String text = "X_X_XXXO";
String patternString = "XXX_|XX_X|X_XX|_XXX";
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher(text);
while(matcher.find()) {
.. code
}