Random_Walk has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex excluding some matches
by choroba (Cardinal) on Jan 04, 2022 at 20:21 UTC | |
Re: regex excluding some matches
by Cristoforo (Curate) on Jan 04, 2022 at 21:05 UTC |