mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Simplify words.
This commit is contained in:
@@ -43,8 +43,14 @@ const rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)'
|
||||
const rsSeq = rsOptVar + reOptMod + rsOptJoin
|
||||
const rsEmoji = `(?:${ [rsDingbat, rsRegional, rsSurrPair].join('|') })${ rsSeq }`
|
||||
|
||||
/** Used to match complex or compound words. */
|
||||
const reUnicodeWord = RegExp([
|
||||
/**
|
||||
* Splits a Unicode `string` into an array of its words.
|
||||
*
|
||||
* @private
|
||||
* @param {string} The string to inspect.
|
||||
* @returns {Array} Returns the words of `string`.
|
||||
*/
|
||||
const unicodeWords = RegExp.prototype.exec.bind(RegExp([
|
||||
`${ rsUpper }?${ rsLower }+${ rsOptContrLower }(?=${ [rsBreak, rsUpper, '$'].join('|') })`,
|
||||
`${ rsMiscUpper }+${ rsOptContrUpper }(?=${ [rsBreak, rsUpper + rsMiscLower, '$'].join('|') })`,
|
||||
`${ rsUpper }?${ rsMiscLower }+${ rsOptContrLower }`,
|
||||
@@ -53,17 +59,6 @@ const reUnicodeWord = RegExp([
|
||||
rsOrdLower,
|
||||
rsDigits,
|
||||
rsEmoji
|
||||
].join('|'), 'g')
|
||||
|
||||
/**
|
||||
* Splits a Unicode `string` into an array of its words.
|
||||
*
|
||||
* @private
|
||||
* @param {string} The string to inspect.
|
||||
* @returns {Array} Returns the words of `string`.
|
||||
*/
|
||||
function unicodeWords(string) {
|
||||
return string.match(reUnicodeWord) || []
|
||||
}
|
||||
].join('|'), 'g'))
|
||||
|
||||
export default unicodeWords
|
||||
|
||||
Reference in New Issue
Block a user