Re: tough regex problem

Uri Guttman <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
>>>>> "JG" == Josh Goldberg <[email protected]> writes:

  JG> How about this?
  JG>      return grep(/./s, $$bufref =~ m#(.*?)(?:$sep|\z)#gs) if wantarray;

check that on an empty file. it needs to return a null string for
that. the grep will fail there. and i don't want to filter it through
grep as that will slow it down.

as i said, it is trickier than meets the eye. that is why i settled on
the split with lookbehind as it works properly in all the corner cases.

uri

-- 
Uri Guttman  ------  [email protected]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.