mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-14 04:37:50 +00:00
Add _.words tests and tweak reWords regexp.
This commit is contained in:
@@ -105,11 +105,10 @@
|
|||||||
|
|
||||||
/** Used to match words to create compound words */
|
/** Used to match words to create compound words */
|
||||||
var reWords = (function() {
|
var reWords = (function() {
|
||||||
var nums = '[0-9]',
|
var upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]',
|
||||||
upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]',
|
lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+';
|
||||||
lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+' + nums + '*';
|
|
||||||
|
|
||||||
return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|' + nums + '+', 'g');
|
return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/** Used to detect and test whitespace */
|
/** Used to detect and test whitespace */
|
||||||
|
|||||||
10
test/test.js
10
test/test.js
@@ -11657,6 +11657,16 @@
|
|||||||
|
|
||||||
deepEqual(actual, [['a'], ['b'], ['c']]);
|
deepEqual(actual, [['a'], ['b'], ['c']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should work with compound words', 6, function() {
|
||||||
|
deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']);
|
||||||
|
deepEqual(_.words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']);
|
||||||
|
deepEqual(_.words('aeiou2Consonants'), ['aeiou', '2', 'Consonants']);
|
||||||
|
|
||||||
|
deepEqual(_.words('LETTERSÆiouAreVowels'), ['LETTERS', 'Æiou', 'Are', 'Vowels']);
|
||||||
|
deepEqual(_.words('æiouAreVowels'), ['æiou', 'Are', 'Vowels']);
|
||||||
|
deepEqual(_.words('æiou2Consonants'), ['æiou', '2', 'Consonants']);
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user