Regular Expressions 101

Community Patterns

Check sudoku

1

Regular Expression
PCRE (PHP <7.3)

/
^(?!.*(?=(.))((.{9})+|(.(?!(?3)*$))+|(?(?=.(...)*$)(.(?!(.{27})*$)){7}|.)+)\1)
/

Description

Check if a sudoku board is valid or not. The board has to be as a single line. Seen at http://codegolf.stackexchange.com/questions/78210/regex-golf-verify-a-sudoku-solution

Submitted by anonymous - 8 years ago