[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RE question
no, it works, you just need to add the s flag..
gooz:~ >cat /tmp/aa
$_ = '
/* Yadda /
* Yadda /
* Yadda */
';
m[/\*(.*?)\*/]s;
print "$1\n";
gooz:~ >perl /tmp/aa
Yadda /
* Yadda /
* Yadda
gooz:~ >
On Fri, Apr 02, 1999 at 12:13:21PM -0700, Bobby Kleemann sent me this...
> But this one wouldn't match
>
> /* Yadda /
> * Yadda /
> * Yadda */
>
> This is probably going ot have to be done in a multi-stage attempt.
>
> ... =~ m!
> (/\* # Begin comment
> .*? # Match everything except *'s
> \*/) # End comment
> # Rest of function matching code.
> !sx;
>
> while (m!(\*/)!sg > 1) {
> # If there is any nested comments, remove them.
> s!.*/\*.*?\*/!!s;
> }
>
> _ _ _
> Bobby Kleemann <neta.rkleeman@com>
> http://www.neta.com/~rkleeman/
>
> On Thu, 1 Apr 1999, Dan Haskovec wrote:
>
> > $foo =~ m|/\*[^*/]*\*/|;
> >
> > Also look at the concept of "greedy matching," can't remember the operator
> > for that exactly. That way you could just match the first close comment.
> >
> > dan
> >
> >
> > On Thu, 1 Apr 1999, Doug Shea wrote:
> >
> > > So what I'm getting at here, I want to match an open comment ("/*"),
> > > then anything that DOESN'T include an open comment, then a close comment
> > > ("*/"). I think that'll do it, but I don't know how to specify an RE
> > > that means "anything that doesn't include"...
> >
>