Results 1 to 2 of 2
  1. #1
    toad is offline Member
    Join Date
    Oct 2007
    Rep Power

    Default 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.

    Java 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.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Rep Power

Similar Threads

  1. Replies: 4
    Last Post: 07-07-2008, 01:32 PM
  2. Extracting JAR file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:17 AM
  3. Extracting embedded files
    By kasturi in forum New To Java
    Replies: 0
    Last Post: 02-07-2008, 12:25 PM
  4. Analyze a string of words
    By zoe in forum Advanced Java
    Replies: 2
    Last Post: 07-26-2007, 10:01 AM
  5. Extracting data from an XML file...
    By techno_brains in forum New To Java
    Replies: 1
    Last Post: 07-15-2007, 05:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts