On Thu, Sep 17, 2009 at 16:23, Noah Garrett Wallach
<noah-l...@enabled.com> wrote:
> Hi there Perl folks,
>
>
> Okay I am trying to figure this out.
>
> I am trying to match the following:
>
>
> $line = "blah&blah&blah"
>
>
> so I have the following line to match that
>
> $line =~ /((?:blah).*?){0,5}/;
> But I want to capture "blah" in a variable like
> $capture = $1;
>
> or something like that?
>
> am I on the right track?
>
> Cheers,
snip

Depends on what you want.  Your string is "blah&blah&blah", which
means (?:blah){0,5} will match the first four characters: "blah".  The
"&" will prevent it from matching any more.  You may want something
like this instead:

my @matches = $line =~ /\b(blah)\b/g;

This will return all of occurrences of the word blah.



-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to