getWords()function
getWords(str: string): ImmutableArray<string>
| Param | Type | |
|---|---|---|
str | string | The string to extract words from. required |
| Return | |
|---|---|
ImmutableArray<string> | Array of the separate words and quoted phrases found in str. |
Return an array of the separate words and "quoted phrases" found in a string.
- Phrases enclosed "in quotes" are a single word.
- Performs no processing on the words, so control chars, punctuation, symbols, and case are all preserved.
Note: this splits words based on spaces, so won't work well with logographic writing systems e.g. kanji.
Examples
getWords(`a "b c" d`) // ["a", "b c", "d"]