John W. Krahn wrote:
> Rob Dixon wrote:
> >
> > John W. Krahn wrote:
> > >
> > > Better to use zero-width positive look-ahead and look-behind.
> > >
> > > $ perl -le'
> > > $_ = ":B000:L520:M260:M:88:8:M602:";
> > > $string_to_match = qr/\w+/;
> > > $count = () = /(?<=:)$string_to_match(?=:)/g;
> >
Rob Dixon wrote:
>
> John W. Krahn wrote:
> >
> > Using a character class like \W won't work properly if $string_to_match
> > is non-null.
> >
> > $ perl -le'
> > $_ = ":B000:L520:M260:M:88:8:M602:";
> > $string_to_match = qr/\w+/;
> > $count = () = /\b$string_to_match\b/g;
> > print $count;
> > '
; cc:
Subject: Re: Preventing null string
from matching
John W. Krahn wrote:
> Rob Dixon wrote:
> >
> > my @match = /\W($string_to_match)\W/g;
> > my $count =- @match;
>
> Using a character class like \W won't work properly if $string_to_match
> is non-null.
>
> $ perl -le'
> $_ = ":B000:L520:M260:M:88:8:M602:";
> $string_to_match = qr/\w+/;
> $
Rob Dixon wrote:
>
> Scott E Robinson wrote:
> >
> > I don't exactly want to ask this now, since I just spent much of the
> > evening trying to handle this case, but I wonder if there's an easy
> > way to
> > keep the following regular expression from matching if the string in
> > the
> > regex i
Scott E Robinson wrote:
>
> I wasn't complaining about working all evening, by the way -- just
> highlighting how little I know about Perl since a little thing like that
> can keep me here all night!
And I was sympathising, not apologising: I've been there too!
Cheers,
Rob
--
To unsubscribe
.co.uk> cc:
Subject: Re: Preventing null string
from matching
Scott E Robinson wrote:
> Dear Perl communinty,
>
> I don't exactly want to ask this now, since I just spent much of the
> evening trying to handle this case, but I wonder if there's an easy
> way to
> keep the following regular expression from matching if the string in
> the
> regex is null:
>
>
Scott E Robinson wrote:
> Dear Perl communinty,
>
> I don't exactly want to ask this now, since I just spent much of the
> evening trying to handle this case, but I wonder if there's an easy
> way to
> keep the following regular expression from matching if the string in
> the
> regex is null:
>
>
Scott E Robinson <[EMAIL PROTECTED]> wrote:
>
> [...] I wonder if there's an easy way to keep the following
> regular expression from matching if the string in the regex
> is null:
>
> $_ = ":B000:L520:M260:M:88:8:M602:";
> $string_to_match="whatever";
> $count = () = /\b($string_to_match)\b/g;
Dear Perl communinty,
I don't exactly want to ask this now, since I just spent much of the
evening trying to handle this case, but I wonder if there's an easy way to
keep the following regular expression from matching if the string in the
regex is null:
$_ = ":B000:L520:M260:M:88:8:M602:";
$str
11 matches
Mail list logo