[Chicago-talk] REGEX question

Richard Solberg flateyjarbok at yahoo.com
Sat Apr 17 07:14:29 CDT 2004

Thanks for the input Pete, Mike, and Steven.
Steven I have a follow up question.

--- Steven Lembark <lembark at wrkhors.com> wrote:
> Assign the result of globally applying a regex
> to the buffer and you'll get everything that
> maches in one pass:
> 	my $regex = /(whatever)(matches)/;
> 	my @result = $buffer =~ /$regex/g;
> You can also use a while loop with \Z to match
> where the last regex left off.

I am missing the last portion on regex's but not sure
where you would use the \Z.  Can you write a while
loop example?

> One nice trick with split is that it can capture
> what was used to split on (nice if the separator
> varies between runs or within the buffer):
> 	my @stuff = split /(\W+)/, $buffer;
> will split the buffer on non-word char's and
> save both the matched portion from the regex
> and the split-out pieces between.

This works for me once I include the (  ) around the
\W+.   Doesn't seem to work though if I want to put
()'s inside the outer ()'s.  Can you put variables or
either|or () inside.

@stuff = split /(<td>(.*?)<\/td>) / , $buffer

to capture a varible


@stuff = split /(<td>\w+(.|\/|\0)<\/td> ) / , $buffer

to capture word characters that may have a "." , "/"
or just all word characters?  All surrounded by the
<td> and </td>

examples are

Thanks much.

> --
> Steven Lembark
> Workhorse Computing
> +1 888 359 3508
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at mail.pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk

Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th

More information about the Chicago-talk mailing list