Leser: 18
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+)
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"; }
2011-03-18T15:19:52 kimmyHallo,
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... if ($line =~ /\s($reg)\s/) { my $treffer = $1; $line =~ s/$1/\($treffer\)/g; }
Mein Skript läuft ja schon, aber nur einen Treffer pro Zeile.