I would like to parse entire file based on all the possible delimiters like commas, colon, semi colons, periods, spaces, hiphens etcs.
Suppose I have a hypothetical string line “Hi,X How-how are:any you?” I should get output array with items Hi,X,How,how,are,any and you.
How do I specify all these delimiter in String.split method?
Thanks in advance.
String.splittakes a regular expression, in this case, you want non-word characters (regex\W) to be the split, so it’s simply:If you wanted to be more explicit, you could use the exact characters in the expression: