RegexWars
Tier 4 · Enchantermatch

FEN Shape

Validate the short two-field FEN: eight ranks separated by slashes, then a space and the active colour.

A rank is one or more of the piece letters — p n b r q k for black, P N B R Q K for white — and the digits 1 to 8, which stand for runs of empty squares. Exactly eight ranks, so exactly seven slashes, then one space and either w or b, and nothing else at all: the full six-field FEN is a different string and must be rejected. Do not try to check that each rank adds up to eight squares. That is arithmetic, and a regular expression cannot count.

Your pattern0 chars · par 51
//
Flags
Start typing — tests run as you go.0 of 9 visible tests passing
Test cases
  • rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR wmust match

    the starting position

  • 8/8/8/8/8/8/8/8 bmust match

    an empty board is still well formed

  • r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R wmust match
  • rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP wmust not match

    only seven ranks

  • rnbqkbnr/pppppppp/8/8/8/8/8/PPPPPPPP/RNBQKBNR wmust not match

    nine ranks

  • rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNRmust not match

    no active colour

  • rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR xmust not match

    x is not a colour

  • rnbqkbnr/ppppXppp/8/8/8/8/PPPPPPPP/RNBQKBNR wmust not match

    X is not a piece

  • rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1must not match

    the six-field form is not this

+ 13 hidden tests, checked when you submit. They are what stops a pattern that only fits the examples above.