diff --git a/lodash.js b/lodash.js index b49de1fbf..5e11ea9ac 100644 --- a/lodash.js +++ b/lodash.js @@ -99,7 +99,13 @@ var reUnescapedString = /['\n\r\u2028\u2029\\]/g; /** Used to match words to create compound words */ - var reWords = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*)|[A-Z]?[a-z]+[0-9]*|[A-Z]+|[0-9]+/g; + var reWords = (function() { + var nums = '[0-9]', + upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]', + lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+' + nums + '*'; + + return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|' + nums + '+', 'g'); + }()); /** Used to detect and test whitespace */ var whitespace = ( @@ -8773,7 +8779,7 @@ * // => ['fred', 'barney', '&', 'pebbles'] */ function words(string, pattern) { - string = string == null ? '' : String(string); + string = string != null && String(string); return (string && string.match(pattern || reWords)) || []; } diff --git a/test/test.js b/test/test.js index f5e7644f8..01d8395e7 100644 --- a/test/test.js +++ b/test/test.js @@ -1320,7 +1320,7 @@ return func(string) === expected; }); - ok(_.every(actual)); + deepEqual(actual, _.map(strings, _.constant(true))); }); test('`_.' + methodName + '` should handle double-converting strings', 1, function() { @@ -1328,15 +1328,15 @@ return func(func(string)) === expected; }); - ok(_.every(actual)); + deepEqual(actual, _.map(strings, _.constant(true))); }); test('`_.' + methodName + '` should deburr letters', 1, function() { var actual = _.map(burredLetters, function(burred, index) { - return func(burred) == deburredLetters[index].toLowerCase(); + return func(burred) === deburredLetters[index].toLowerCase(); }); - ok(_.every(actual)); + deepEqual(actual, _.map(burredLetters, _.constant(true))); }); test('`_.' + methodName + '` should coerce `string` to a string', 2, function() {