Thread Regex über mehrere Zeilen (10 answers)
Opened by padpaf at 2013-08-29 16:18

Linuxer
 2013-08-29 17:01
#169818 #169818
User since
2006-01-27
3890 Artikel
HausmeisterIn

user image
Naja, fange den String mit runden Klammern ein und gebe $1 anstatt $_ aus...

Edit(2x)
Beispiel:
Code: (dl )
1
2
3
4
5
6
$ perl -00 -wnl -e '/\S+ OBJECT-TYPE/ and print;' mib.txt  | perl -00  -wnl -e '/(".*")/s and print $1;'
"The number of received packets that are either undersized,
oversized, or have FCS errors."

"The number of received packets that are either undersized,
oversized, or have FCS errors."


mib.txt
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    foo OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The number of received packets that are either undersized,
oversized, or have FCS errors."
::= { foo 8 }

bar OBJECT-TYPE
SYNTAX Counter64
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The number of received packets that are either undersized,
oversized, or have FCS errors."
::= { bar 8 }

Last edited: 2013-08-29 17:03:59 +0200 (CEST)
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread Regex über mehrere Zeilen