Thread Regex Frage (23 answers)
Opened by bianca at 2012-11-09 17:42

bianca
 2012-11-09 17:42
#163194 #163194
User since
2009-09-13
6977 Artikel
BenutzerIn

user image
Hi!
Bitte gebt mir nochmal kurz Hilfe für ein Regex.
Wie muss der Regex in diesem Script aussehen, damit er auf beides matcht?
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl
use strict;
use warnings;

my @test;
push @test,'[Thu Nov 08 22:59:19 2012] [error] Hostname www.......de provided via SNI, but no hostname provided in HTTP request';
push @test,'[Fri Nov 09 09:49:30 2012] [error] [client 8.1.1.1] Can\'t modify constant item in scalar assignment at /script.pl line 16, near "\'schiess mich tot\';", referer: https://.......pl';
for (my $z = 0; $z < scalar @test; $z++) {
    print "Zeile $z: ";
    if (
        $test[$z] =~ /^\[[^ ]+ ([^ ]+)  ?([0-9]+) ([0-9:]+) ([0-9]+)\] \[([^\]]+)\] \[[^ ]+ ([^\]]+)\] (.*)$/
    ) {
        print "matcht 7=>$7<\n";
    }
    else {
        print "matcht nicht\n";
    }
}

Danke
10 print "Hallo"
20 goto 10

View full thread Regex Frage