@pmun/utils / words
Function: words()
ts
function words(str): string[];将字符串分割成单词数组
Parameters
str
string
要分割的字符串
Returns
string[]
单词数组
Example
ts
words('hello world') // ['hello', 'world']
words('helloWorld') // ['hello', 'World']
words('hello-world-foo') // ['hello', 'world', 'foo']
words('hello_world_foo') // ['hello', 'world', 'foo']
words('HelloWorldFoo') // ['Hello', 'World', 'Foo']
words('hello123world') // ['hello', '123', 'world']