I'm trying to split an input by ".,:;()[]"'\/!? "
chars and add the words to a list. I've tried .split("\\W+?")
and .split("\\W")
, but both of them are returning empty elements in the list.
Additionally, I've tried .split("\\W+")
, which returns only words without any special characters that should go along with them (for instance, if one of the input words is "C#", it writes "C" in the list). Lastly, I've also tried to put all of the special chars above into the .split()
method: .split("\\.,:;\\(\\)\\[]\"'\\\\/!\\? ")
, but this isn't splitting the input at all. Could anyone advise please?