I've got some quick and dirty code that I'm using to parse some logs. A typical line that I'm feeding to my regex looks like this:
ASCII data in TCP pkt from 111.11.111.111/1162 to local port 7070: !
The regex I'm using looks like this:
/[^\d]+([^ ]+)[^\d](\d+)(.*?)$/; print "$1\n$2\n$3\n";
This should yield:
111.11.111.111/1162 7070 !

It doesn't.
What I get instead is this:
111.11.111.111 1162 to local port 7070: !

For some reason the ([^ ]+) section stops at the forward slash, even though it's clearly not a space.
If I change that part of the RE to ([^ ]+?), making it less greedy, it stops matching at the first period in the IP address, even though a period is still not a space!
I'm at a loss to explain why this seemingly simple RE insists on frappeing my brain. Anybody run into something similar? Am I missing some key knowledge that I should be smacking my forehead and saying "D'oh!" for? FWIW, I'm using ActiveState's Perl 5.6 in case this may be one of those bugs I keep hearing about.
TIA


Guildenstern
Negaterd character class uber alles!

In reply to Matching (non)spaces in regex? by Guildenstern

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.