9 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9
#!/usr/bin/perl -w use strict; my $string = '2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - -'; if($string =~ m![1-8pPbBnNrRqQkK]+/[1-8pPbBnNrRqQkK]+/[1-8pPbBnNrRqQkK]+/[1-8pPbBnNrRqQkK]+/[1-8pPbBnNrRqQkK]+/[1-8pPbBnNrRqQkK]+/[1-8pPbBnNrRqQkK]+/[1-8pPbBnNrRqQkK]+ [wb] [-KkQq] [-a-h36]+!) { print "yo"; }
m!(?:[1-8pPbBnNrRqQkK]+/){7}[1-8pPbBnNrRqQkK]+ [wb] [-KkQq] [-a-h36]+!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!/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 (<DATA>) { 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 - -
1
2
3
4
5
6
7
8
9
10
$ perl match.pl
2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - -: ja
2/8/Np/6pk/5P1P/6P1/7r/5r2 w - -: nein
/2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - -: nein
2B3Y1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - -: nein
2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 W - -: nein
2B3K1/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 - -: nein
2B3K1/8/3N1p1p/5P1P/6P1/7r/5r2 w - -: nein
2B3K1/8/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - -: nein
2B3K1/8/8/8/3N1p1p/6pk/5P1P/6P1/7r/5r2 w - -: nein
if ($string !~ m/[1-8pPbBnNrRqQkK]+/) {print "Fehler";}
if ($string =~ m/[^1-8pPbBnNrRqQkK]/) {print "Fehler";}
if ($string =~ m/[^1-8pPbBnNrRqQkK]/) {print "Fehler";}
9 Einträge, 1 Seite |