develooper Front page | perl.perl5.porters | Postings from August 2000

Re: Proposal for \v and \V, the small- and large- cut regex operators.

From:
Ilya Zakharevich
Date:
August 10, 2000 00:35
Subject:
Re: Proposal for \v and \V, the small- and large- cut regex operators.
Message ID:
20000810033513.B16784@monk.mps.ohio-state.edu
On Wed, Aug 09, 2000 at 09:53:10PM -0400, Rick Delaney wrote:
> > The most useful may be \F{!<} (FINISH, mark positions before this one
> > as "failing", and restart the whole match).  Since the positions
> > before the given one are marked as "failing", the match will restart
> > at the current position (as if pos() and \G .*? were present).  
> 
> And this one I can think of as "flag" (okay, I'm stretching now).
> 
> I'm not sure if I'm fully understanding this one, though.  Wouldn't this
> regexp need to be grouped and followed by some other regexp to be
> useful?  As it's written I don't see why it needs \F.

*It* needs \F?  Which "it"?  The example is below.

> > Then one could match comments in C code without preprocessor commands 
> > by
> > 
> >   ' ( \\. | [^\\'] )+ ' \F{!<}
> >  |
> >   " ( \\. | [^\\"] )* " \F{!<}
> >  |
> >   /\* .*? */
> 
> If the above is $comments then I can see
> 
>     /($comments)WHATEVER/
> 
> being very useful when WHATEVER isn't found, since \F eliminates all the
> possibilities before it (if I'm following).

It is supposed to be used as /$comment/.   Consider

  const char * comment_start = "/*";	     /* Assume C by defaut */

The above REx will correctly find the comment in this line.

Hope this is clearer,
Ilya



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About