- or download this
^(...)*(X|O)\2\2|(X|O)(.{2,3}\3)\4|^..(X|O).\5.\5
- or download this
#!/usr/bin/perl -w
# Test regular expression on Tic Tac Toe boards.
...
sub is_win {
return shift =~ m/^(...)*(X|O)\2\2|(X|O)(.{2,3}\3)\4|^..(X|O).\5.\5/
+;
}
- or download this
^(...)*(\w)\2\2|^..(\w).\3.\3|(\w)..\4..\4|(\w)...\5...\5
- or download this
(\w)(..(\1|.\1.)..\1|.\1.\1..$|\1\1(...)*$)