def lines2board(lines):
    """Parse a text board stripping spaces and setting 0's for empty squares."""
    spaces = re.compile("\s+")
    return [[(int(c) if c in "123456789" else 0) for c in spaces.sub("", line)]
            for line in lines if line.strip()]
Parse a text board stripping spaces and setting 0's for empty squares.
recipes/Python/577188_Sudoku_solver_functionalprogramming/recipe-577188.py