As the title suggests:
I’m trying to split sentences into either a comma-separated string or array consisting of sanitized words greater than 2 characters in length and unique (duplicates removed).
An example string might be:
$sString = 'Stackoverflow's users are awesome!!! Stackoverflow, is the "best" technical questions and answers website on the interwebnet!';
Finished article:
$sStringAfterProcessing = 'stackoverflow, users, are, awesome, the, best, technical, questions, and, answers, website, interwebnet';
Note the first stackflow has the ‘s removed, punctuation and duplicates are removed.
This seems like it could get very complicated.
Suggestions welcome and all help is much appreciated.
Here goes…
will yield:
Example: http://jsfiddle.net/ktFj2/1/
Or, in array format:
Example: http://jsfiddle.net/nnKV8/
Update: To remove duplicates from the array (and items with length
< 2), something like this: