#!/usr/bin/perl use warnings; use strict; # Untermuster, Groß-/Kleinschreibung nicht unterschieden my $submuster = qr/(?i)[1-8pbnrqk]+/; # Testdaten - nur der erste String ist korrekt! for my $string () { chomp $string; if($string =~ m!^(?:$submuster/){7}$submuster [wb] [-KkQq] [-a-h36]+$!) { print "$string: ja"; } else { print "$string: nein"; } print "\n"; } __DATA__ 2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - - 2/8/Np/6pk/5P1P/6P1/7r/5r2 w - - /2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - - 2B3Y1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - - 2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 W - - 2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 - - 2B3K1/8/3N1p1p/5P1P/6P1/7r/5r2 w - - 2B3K1/8/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - - 2B3K1/8/8/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - -