harvesthq/chosen — pull request #1483 by pfiller (2013-08-16 22:13:41+00:00)
Title: Use word boundary matching

@harvesthq/chosen-developers

This is a new PR for @koenpunt's excellent #1465. In his words:

> By making use of word boundary matching (http://www.regular-expressions.info/wordboundaries.html) the split word search is much cleaner (no more actual splitting of strings), and the search results are better.

I want to be very careful about merging this in, but I'm loving what I see so far. With default options set:

Search String
Expected to Match
Old way
New way

Democratic Republic of
Congo, The Democratic Republic of The
:poop:
:+1:

of America
United States (of America)
:poop:
:+1:

Here's what I think we should do before this gets a final :shipit:

- [ ] Add unit tests for verifying that search results are correct. To do this, we might need to break the actual search match function out of the winnow method.
- [ ] Performance Test with 1000s of items (perhaps replacing test + match with a single match call)
- [ ] Determine if we need to make an API change related to `enable_split_word_search` or `search_contains`. I don't think you should be able to turn off `enable_split_word_search` if `search_contains` is `true`, but I want to do some experimenting there.

Fixes #75 and #1463