I need my Java program to take a string like:
\"This is a sample sentence.\"
and turn it into a string array like:
{\"this\
Now, this can be accomplished just with split as it takes regex:
String s = "This is a sample sentence with []s.";
String[] words = s.split("\\W+");
this will give words as: {"this","is","a","sample","sentence", "s"}
The \\W+ will match all non-alphabetic characters occurring one or more times. So there is no need to replace. You can check other patterns also.