I have a test.txt file containing several lines, for example:
"h3llo, @my name is, bob! (how are you?)" "i am fine@ @@@@"
I want to split all alphanumeric characters and a new line into arraylist so that the output is
output = ["h", "llo", "my", "name", "is", "bob", "how", "are", "you", "i", "am", "fine"]
At the moment, I tried to split my text with
output.split("\\P{Alpha}+")
But for some reason this seems to add a comma to the first place in the arraylist and replace the new line with an empty line
output = ["", "h", "llo", "my", "name", "is", "bob", "how", "are", "you", "", "i", "am", "fine"]
Is there any other way to fix this? Thanks!
-
EDIT: How can I make sure it ignores a new line?