Skip to content

Commit

Permalink
Handles punctuation better
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurt Symanzik committed Sep 5, 2012
1 parent f29ff0f commit 32a78de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/reds.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ exports.createSearch = function(key){
*/

exports.words = function(str){
return String(str).trim().split(/\W+/);
return String(str).match(/\w+/g);
};

/**
Expand Down
6 changes: 5 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ var start = new Date;
reds.version.should.match(/^\d+\.\d+\.\d+$/);

reds
.words('foo bar baz')
.words('foo bar baz ')
.should.eql(['foo', 'bar', 'baz']);

reds
.words(' Punctuation and whitespace; should be, handled.')
.should.eql(['Punctuation', 'and', 'whitespace', 'should', 'be', 'handled']);

reds
.stripStopWords(['this', 'is', 'just', 'a', 'test'])
.should.eql(['just', 'test']);
Expand Down

0 comments on commit 32a78de

Please sign in to comment.