Hi,

Russ Allbery wrote:

> --- a/lib/Spelling.pm
> +++ b/lib/Spelling.pm
> @@ -575,9 +575,10 @@ sub spelling_check {
>      return unless $text;
>  
>      $text = lc $text;
> -    $text =~ s/[.,;:?!()[\]]//g;
> +    $text =~ s/[()[\]]//g;
>  
>      for my $word (split(/\s+/, $text)) {
> +        $word =~ s/[.,;:?!]+$//;

May I suggest moving that regex out of the for loop? it is faster to apply a
regex to a large string once than applying it to lots of small strings.

The following regex should do it:
$text =~ s/(?:[()[\]]|[.,;:?!]+(?=\s))//g;

Cheers,
-- 
Raphael Geissert - Debian Maintainer
www.debian.org - get.debian.net



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to