Thread regex - Probleme! (19 answers)
Opened by Weman at 2005-09-19 14:54

vayu
 2005-09-21 21:26
#58192 #58192
User since
2005-01-13
782 Artikel
BenutzerIn
[default_avatar]
Code: (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
#!/usr/bin/perl

use warnings;
use strict;

my $word = "WORT";
my $otherword = "ANDRENWORT";
my @satz = ();
$satz[0] = "Ein Text mit einem WORT und noch einem ANDRENWORT sowie einem ANDRENWORT.";
$satz[1] = "Ein Text mit einem WORT und noch einem WORT sowie einem ANDRENWORT.";
$satz[2] = "Ein Text mit einem ANDRENWORT und noch einem WORT sowie einem ANDRENWORT.";
$satz[3] = "Ein Text mit einem ANDRENWORT und noch einem ANDRENWORT sowie einem WORT.";
$satz[4] = "WORT und ein Text mit einem ANDRENWORT und noch einem ANDRENWORT sowie einem WORT";

foreach(@satz) {

print $_."\n";
if($_ =~ /(^.*?)\b$word\b.*/) {
print $1."\n";
}
if($_ =~ /.*(\b$word\b(.*?)\b$otherword\b).*/) {
print $2."\n";
}
print "__\n";
}


dann gehts doch jetzt aber so :)

View full thread regex - Probleme!