mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Implement asciiWords and unicodeWords using String.match instead of binding RegExp.exec (#4417)
* Enable words tests * Implement asciiWords and unicodeWords using String.match instead of binding RegExp.exec
This commit is contained in:
committed by
John-David Dalton
parent
15e1557b2a
commit
e2555a43ad
11
words.js
11
words.js
@@ -1,13 +1,16 @@
|
||||
import unicodeWords from './.internal/unicodeWords.js'
|
||||
|
||||
const asciiWords = RegExp.prototype.exec.bind(
|
||||
/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g
|
||||
)
|
||||
|
||||
const hasUnicodeWord = RegExp.prototype.test.bind(
|
||||
/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/
|
||||
)
|
||||
|
||||
/** Used to match words composed of alphanumeric characters. */
|
||||
const reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g
|
||||
|
||||
function asciiWords(string) {
|
||||
return string.match(reAsciiWord)
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits `string` into an array of its words.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user