View Single Post
  #1 (permalink)  
Old 11-04-2007, 06:00 PM
toad toad is offline
Member
 
Join Date: Oct 2007
Posts: 11
toad is on a distinguished road
program help: Extracting words from a string
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.

Code:
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.
Reply With Quote
Sponsored Links