On Thu, Oct 27, 2011 at 03:02:33PM -0400, Ronald J Kimball wrote:

> my $re =
>   '\b(' . join('|', sort { length $b <=> length $a } keys %dict) . ')\b';

I just realized I forgot one thing.  This should be:

my $re =
  '\b(' .
    join('|', map "\Q$_\E", sort { length $b <=> length $a } keys %dict) .
  ')\b';

in case the terms contain special characters.  "\Q$_\E" will escape the
special characters with backslashes.

Ronald

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to