Thread Text Tagging
(1 answers)
Opened by kimmy at 2011-03-18 16:19
Hallo,
ich habe eine Liste von RegEx, und damit hätte ich gern einen Text durchsuchen und taggen. 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 ([A-Z0-9]+\-[A-Z0-9]+(\-[A-Z0-9]+)*) (([A-Z]+\-)*\d+\-+\d+\-+\d+\-*[A-Z\d]*) ([A-Z]+\d+[A-Z]+\-\d+[A-Z]+\d*) ([A-Z]+\d+\-[A-Z]+\-*\d+[A-Z]+\d*) (\d+\.\d\d\d+) ([A-Z]+\-[A-Z]+[\-A-Z]*\-\d+) (\d\d\d+\-[A-Z\d]+[A-Z\d]*) ([A-Z]+\d+[A-Z]+\-[A-Z\d]+[A-Z\d]+[A-Z]*) ([A-Z]+\-\d+\-\d+) ([A-Z]+\d+\-\d+\-[A-Z]+\-[A-Z]+) (\d+\-\d+\-[A-Z]+) (\d+[A-Z]*\-[A-Z]+\-[A-Z]+) (\d+[A-Z]+\d+\-\d*[A-Z]*) (\d+\.\d+\.\d+\.*\d*) ((\d\d\d\d)+[A-Z]+) (\d+\-[A-Z]+\-\d*[A-Z]*) (\d\d+\,\d+) ([A-Z]+\-[A-Z]+\d+(\-[A-Z]\d)*) ([A-Z]+\d+\-*[A-Z]+\d+\-*[A-Z]+\-*\d+\-*[A-Z]+\d*) ([A-Z][A-Z]+\-*\d\d+[A-Z]*[A-Z\d]*) ([A-Z]+\d+\-?([A-Z]*\d*)*) (\d\d+[A-Z]+\d+[A-Z0-9]*\-*[A-Z]*) (\d\d+[A-Z][A-Z][A-Z]+[a-zA-Z0-9]*) ([A-Z]+\-*\d+[A-Z]+[A-Z\d]*) (\d+\-\d+) (\d\d\d\d+) Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #!/usr/bin/perl use strict; use warnings; use Encode; binmode(STDOUT,":utf8"); open(my $regex, "regex.txt") or die; my @regex = <$regex>; while(<>){ chomp; my $line = $_; foreach my $reg(@regex){ chomp $reg; if($line =~ /\s($reg)\s/){ my $treffer = $1; $line =~ s/$1/\($treffer\)/g; } } print "$line\n"; } Mein Skript läuft ja schon, aber nur einen Treffer pro Zeile. Aber was ich haben möchte ist, mehrere Treffer pro Zeile, falls es gibt. Wie kann ich mein Skript ändern? Vielen Dank im Voraus. |