[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RE question
if it's the same expression, why did you say it wouldn't work?
and i don't understand you forward and backward ungreedyness...
your original example had one comment in it, and that worked for one comment.
if you mean having multiple comments, then the simplest way to do it is with
a loop.. i'm not sure if i just misunderstood you or not..
gooz:~ >cat /tmp/aa
$_ = '
/* Yadda /
* Yadda /
* Yadda */
/* this is
another comment */
';
while (s[/\*(.*?)\*/][]s){
$a = $1;
$a =~ s/\n/ /g;
print "comment [$a]\n";
}
gooz:~ >perl /tmp/aa
comment [ Yadda / * Yadda / * Yadda ]
comment [ this is another comment ]
On Fri, Apr 02, 1999 at 12:54:59PM -0800, Doug Shea sent me this...
>
>
> --- Reza Naima <reza.reza@net> wrote:
> > well, this kinda works..
> >
> > $_ = 'comment /* this is a * test dumbass /* */ foo */';
> >
> > m[/\*(.*?)\*/];
> > print "$1\n";
> >
>
> Syntactic differences aside, that's exactly what I already have...
>
> /(\\\*.*?\*\\)/
>
> That's the one that matches from the beginning of the first comment
> to the end of the last comment before the rest of the pattern. The
> un-greedy-ness doesn't help, in this case; there's no way to make it
> BACKWARDS-un-greedy, only FORWARDS un-greedy.
>
> ===
>
> Doug
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free yahoo.@com address at http://mail.yahoo.com