3 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
my $s = qq~['S', ['NP', ['XP', ['YP', ['ZP'], ['ZP']]] 'VP']]~;
my $wort = qr/\[\'\w+\'\](?:\,\s)*/;
my $struktur;
$struktur = qr/
(?:
\[\'\w+\'\,\s
($wort|$struktur)+
\]
(?:\,\s)*
)+
/x;
if( $s =~ $struktur ) {
print "gefunden!\n";
print $&;
}else{
print "nicht gefunden :-(\n";
}
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/perl use strict; use warnings; my $string = qq~['S', ['NP', ['XP', ['YP', ['ZP'], ['ZP']]] 'VP']]~; our $pat; $pat = qr!\[(?>(?>[^\[\]]+)|(??{$pat}))*\]!; if( $string =~ /^($pat)$/ ){ print "matcht $1!\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl use strict; use warnings; my $string = qq~['X', ['S', ['Y', ['X0']], ['NP', ['YP', ['ZP']], 'VP'], 'DA']]~; our $pat; $pat = qr! \[ (?> (?>[^\[\]]+) | (??{$pat}) )* \](?:\,\s)* !x; if( $string =~ /\[\'S\'\,\s($pat)*\[\'NP\'/ ) { print "matcht $1!\n"; print "alles: $&\n"; }else{ print "nix gefunden :-(\n"; }
3 Einträge, 1 Seite |