/me greets [Ovid]

On Aug 20, Curtis Poe said:

>First, I added the caret to force matching from the beginning of the line so we don't 
>accidentally
>match embedded whitespace.  That may or may not matter, depending upon the structure 
>of the data,
>but since I haven't seen the rest of the thread, I'm not sure.

That can never be a problem when using the * quantifier.  Any regex of the
form

  /(THIS)*/

will always match at the beginning of a string.

>    my $leading = $str =~ /^(\s+)/ ? length $1 : 0;

I'd just use the \s* approach and take the length of $1 regardless.

  my $leading = $str =~ /(\s*)/ && length $1;

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


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

Reply via email to