I need to write a program that extracts words from a string using spaces and punctuation marks as delimiters. The string needs to be entered from an input dialog box.
I am lost on this one.
import java.util.*;
import javax.swing.JOptionPane;
public class Exercise8_17 {
/**Main method*/
public static void main(String[] args) {
// Receive text entered from the dialog box
String s = JOptionPane.showInputDialog(
"Enter a sentence using punctuation:");
String delims = "[ .,?!]+";
String[] tokens = str.split(delims);
System.out.println("The extracted words are:");
}
}
This is what I have so far. Am I close.