So I want to split a string in java on any non-alphanumeric characters.
Currently I have been doing it like this
words= Str.split(\"\\\\W+\");
words = Str.split("[^\\w']+");
Just add it to the character class. \W is equivalent to [^\w], which you can then add ' to.
\W
[^\w]
'
Do note, however, that \w also actually includes underscores. If you want to split on underscores as well, you should be using [^a-zA-Z0-9'] instead.
\w
[^a-zA-Z0-9']