String.splitWords
splitWords($keepPunctuation = false)
Description
Split into a List of words, separated by whitespace (newlines and spaces).
Non-alphanumeric characters are removed unless $keepPunctuation
is true
.
'Deer Snail Sparrow'.splitWords(); //= ['Deer', 'Snail', 'Sparrow'] 'Yes, this is a phrase.'.splitWords(); //= ['Yes', 'this', 'is', 'a', 'phrase'] 'Yes, this is a phrase.'.splitWords(true); //= ['Yes,', 'this', 'is', 'a', 'phrase.']