You're right about the guess why "(" is necessary. Simply because the "?"
needs a precedence. It's a syntax thing.

"!" does not stand for "not". The combination "?!" stands for a "negative
look-ahead". See e.g. perldoc.perl.org/perlre.html for details.

Regards,
Boris


On Tue, July 9, 2013 16:56, Paul Gilmartin wrote:
> On Tue, 9 Jul 2013 11:34:55 +0200, Boris Lenz wrote:
>
>>does
>>
>>/(?!)/
>>
>>work for you?
>>
> Thanks!  I never woulda thoughta that.  Seems to work for sed and
> grep; nearly an exhaustive sample.  Now I need to try to understand it:
>
> It matches any string which is not ("!") matched by 0 or 1 ("?") copies
> of the null string (which appears between "(" and "?").  The "(" and ")"
> indicate grouping.  I have no idea why that's necessary.  Perhaps
> operator precedence?  Would any of /(?!)/, /(?)!/, or even /()?!/ work
> alike?  Why not?
>
> And, of course, there are many flavors of regex, all with different rules.
>
> Thanks again,
> gil
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to