Thread Probleme mit RegEx und Worttypen
(49 answers)
Opened by Dingels at 2008-07-25 19:00
Wo hast Du bei 3 Schleifen eine Rekursion?
Code (perl): (dl
)
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 #!/usr/bin/perl # vi:ts=4 sw=4 et: use strict; use warnings; my %hash = ( Abend => 'NN', Sonne => 'NN', Haus => 'NN', Abendsonne => 'NN', ); my $text = q~Haus Abendsonne haussonne hurz~; for my $word ( split /\s+/, $text ) { for my $pre ( keys %hash ) { for my $post ( keys %hash ) { if ( $word =~ /^$pre$post$/i ) { print $word, $/; } } } } meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen! |