Good Afternoon all

And sadly it looks like the afternoon of Perl Monks :(

But anyway, I'm looking for some regex guidance so I hope the gurus stil hang around here. I have a field in a | separated line of data that may contain _P_ or may not. The tool I am using to read it needs two distinct regex, one that will match |MyData_P_Rubbish| and only give me MyData and another regex that would match |YourData| and give me YourData but NOT pick up MyData from the previous example

I have \|(?<DataCapture>[^\|]+)_[P][_\|] That picks up the one with _P_ just fine, but I tried using negative zero width assertions and so to capture those without a _P_ something like \|(?<DataCapture>[^\|]+)(?!_[P]_) but it captures the _P_ too and I have no joy. Is it possible?

Is this possible?

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

In reply to regex excluding some matches by Random_Walk

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.