Answers for "turning a sentence to an array java"

0

turning a sentence to an array java

String s = "This is a sample sentence.";
String[] words = s.split("\\s+");
for (int i = 0; i < words.length; i++) {
    // You may want to check for a non-word character before blindly
    // performing a replacement
    // It may also be necessary to adjust the character class
    words[i] = words[i].replaceAll("[^\\w]", "");
}
Posted by: Guest on October-21-2020

Code answers related to "turning a sentence to an array java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language