Thread Problem mit Regex (3 answers)
Opened by deepc at 2008-05-23 12:25

renee
 2008-05-23 12:39
#110155 #110155
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Du musst mit einer while-Schleife und dem g-Modifier arbeiten:
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl

use strict;
use warnings;

my $content = do{ local $/; <DATA> };

while( $content =~ m/(qdisc\s\w*\s\w+\S\d*|class\s\S*\s\w+\S\d*)\s+.*\s*(Sent\s\d+).*(dropped\s\d+).*(overlimits\s\d+)(\S|\S*.*\s*.*)/g ){
   print "$1 $2 $3 $4\n";
}


__DATA__
Mi 23. Mar 07:17:39 CEST 2008

qdisc htb 1: r2q 1 default 0 direct_packets_stat 416 ver 3.17
 Sent 69203 bytes 416 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
qdisc sfq 1111: parent 1:111 limit 128p quantum 1514b flows 128/1024 perturb 10sec 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
qdisc sfq 1112: parent 1:112 limit 128p quantum 1514b flows 128/1024 perturb 10sec 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
qdisc sfq 1123: parent 1:123 limit 128p quantum 1514b flows 128/1024 perturb 10sec 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
qdisc sfq 1124: parent 1:124 limit 128p quantum 1514b flows 128/1024 perturb 10sec 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
qdisc sfq 1125: parent 1:125 limit 128p quantum 1514b flows 128/1024 perturb 10sec 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
qdisc sfq 1131: parent 1:131 limit 128p quantum 1514b flows 128/1024 perturb 10sec 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
qdisc sfq 1132: parent 1:132 limit 128p quantum 1514b flows 128/1024 perturb 10sec 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
class htb 1:132 parent 1:13 leaf 1132: prio 0 quantum 12500 rate 100000bit ceil 500000bit burst 1611b/8 mpu 0b overhead 0b cburst 1661b/8 mpu 0b overhead 0b level 0 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 0 borrowed: 0 giants: 0
 tokens: 128960 ctokens: 26592

class htb 1:123 parent 1:12 leaf 1123: prio 0 quantum 12500 rate 100000bit ceil 1500Kbit burst 1611b/8 mpu 0b overhead 0b cburst 1786b/8 mpu 0b overhead 0b level 0 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 0 borrowed: 0 giants: 0
 tokens: 128960 ctokens: 9530

class htb 1:11 parent 1:1 rate 400000bit ceil 2048Kbit burst 1649b/8 mpu 0b overhead 0b cburst 1855b/8 mpu 0b overhead 0b level 6 
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
 rate 0bit 0pps backlog 0b 0p requeues 0 
 lended: 0 borrowed: 0 giants: 0
 tokens: 33000 ctokens: 7250


Ausgabe:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
C:\>perl regex.pl
qdisc htb 1: Sent 69203 dropped 0 overlimits 0
qdisc sfq 1111: Sent 0 dropped 0 overlimits 0
qdisc sfq 1112: Sent 0 dropped 0 overlimits 0
qdisc sfq 1123: Sent 0 dropped 0 overlimits 0
qdisc sfq 1124: Sent 0 dropped 0 overlimits 0
qdisc sfq 1125: Sent 0 dropped 0 overlimits 0
qdisc sfq 1131: Sent 0 dropped 0 overlimits 0
qdisc sfq 1132: Sent 0 dropped 0 overlimits 0
class htb 1:132 Sent 0 dropped 0 overlimits 0
class htb 1:123 Sent 0 dropped 0 overlimits 0
class htb 1:11 Sent 0 dropped 0 overlimits 0
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Problem mit Regex