http://www.perlmonks.org?node_id=873118

cipher has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am new to perl, I am stuck on regex part of parsing a file, help would be appreciated. I am parsing a log file which has log entries per line. I am loading regex match in a scalar.
I am trying to match this data:
some_fields msg="http_decoder: HTTP.Unknown.Tunnelling" some_fields
This message keeps on changing.
Here is my regex:
/msg=\"+((?:([^:,]+):\s|)([^,]+?)\s*(?:\s*,.*?|)))\"+/
Here is my script:
foreach $message (@logs) { if ($message =~ /msg=\"+((?:([^:,]+):\s|)([^,]+?)\s*(?:\s*,.*?|))\"+/) + { print $message"\n"; } }
I tried online regex tools and this matches the string but when using perl it does not show any result.
I also tried adding the global match /g still does not work. Any clue? I tried several combinations it does not work. If I use the regex:
if ($message =~ /^msg/) - It only gives me msg="http_decoder: as output
I want the entire string
msg="http_decoder: HTTP.Unknown.Tunnelling"
I also tried
(/^msg=\"(.*?)\"+) This also gives me msg="http_decoder: