basant307/AI_Governance_Project
045
1import asciiWords from './_asciiWords.js';2import hasUnicodeWord from './_hasUnicodeWord.js';3import toString from './toString.js';4import unicodeWords from './_unicodeWords.js';5 6/**7 * Splits `string` into an array of its words.8 *9 * @static10 * @memberOf _11 * @since 3.0.012 * @category String13 * @param {string} [string=''] The string to inspect.14 * @param {RegExp|string} [pattern] The pattern to match words.15 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.16 * @returns {Array} Returns the words of `string`.17 * @example18 *19 * _.words('fred, barney, & pebbles');20 * // => ['fred', 'barney', 'pebbles']21 *22 * _.words('fred, barney, & pebbles', /[^, ]+/g);23 * // => ['fred', 'barney', '&', 'pebbles']24 */25function words(string, pattern, guard) {26 string = toString(string);27 pattern = guard ? undefined : pattern;28 29 if (pattern === undefined) {30 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);31 }32 return string.match(pattern) || [];33}34 35export default words;36 