David Storrs wrote:
> Greetings all,
>
> Given this code:
>
>   my $TOKEN_DELIMS = qr/[^\w\-'\$]/;
>   my $text = # string containing the contents of an mbox file
>
>   my @tokens = split /$TOKEN_DELIMS/o, $text;
>
> I end up with a large number of null strings ('') in @tokens.  After
> RTFMing on split, I assume this is because I am matching at the
> beginning/end of the string.  I can't quite grok how to eliminate
> these, however.
>
> I can easily grep them out, but this is a time-sensitive routine,
> and I'd rather just not generate them.  How can I modify my pattern
> (or my string, without losing real data), so that I don't get these
> spurious matches?
>

  my @tokens = $text =~ m/[\w-'\$]+/g;

or did somebody say this already?

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to