maspsr has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I Have the following regex which I use when extracting information from different logfiles:
(?i-xsm:(?<mon>\w+)\s+(?<day>\d+)\s+(?<hour>\d+):(?<min>\d+):(?<sec>\d ++)\s*(?<host>\S+)\s*(?<prog>\S+)\/(?<proc>\S+)\[(?<pid>\d+)\]:\s*(?<i +d>\S+):\s*to=<(?<to>\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)>,\s*r +elay=(?<name>\S+)\[(?<ip>\d+.\d+.\d+.\d+)\]:(?<port>[0-9]+),\s*delay= +(?<time>\d+\.\d+),\s*delays=(?<beforequeue>[0-9.]+)\/(?<inqueue>[0-9. +]+)\/(?<connect>[0-9.]+)\/(?<transmission>[0-9.]+),\s*dsn=(?<status>[ +0-9.]+),\s*status=sent\s*\((?<code>[0-9.]+)(?<message>.*)\))
I would like to extract all the named parameters like ?<mon>,?<day>,.... to make sure that I haven't used same name twice. The string is composed from substring I have in a database. I have tried different approaches but until now without success. I thought I could use some repetitive pattern like
(\?<(a-z+)>+
But I can't make it work. I could use the perl split function and probably get a list og the names.
any ideas ?
best regards
Peter Sørensen/Univ.Of.Southern.Denmark
|
|---|