Thread Benötige Hilfe bei RegEx
(17 answers)
Opened by jogi at 2007-08-04 19:41
Der Ausdruck matcht auch jetzt schon nicht, ohne Komma. Du hast nicht geschrieben, was der Nickname ist. Ich gehe davon aus, dass es WhomtheBelltolls ist, positioniert vor der schließenden Klammer. Ich gehe davon aus, dass Fingerprints nach dem $ anfangen und bis zum ( gehen.
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 my ($nickname, $last_fingerprint) = $line =~ / \A # anchor at start \# # literal number sign \w{3} # month \s \d\d # day \s \d\d:\d\d:\d\d\.\d{3} # timestamp \s \[\w+\] # log level between brackets \s .*? # log msg \s \( # literal paren open .*? # stuff in the parens \s # space preceding the nickname (\w+) # capture the nickname \) # literal paren close : \s \$[0-9A-F]{40}\(\w+\) # literal $, 40 hex digits, paren open, word, paren close \s \$[0-9A-F]{40}\(\w+\) # again \s \$([0-9A-F]{40})\(\w+\) # capture last fingerprint \z # anchor at end /msx; # PBP |