Results 1 to 2 of 2
  1. #1
    Brian-82 is offline Member
    Join Date
    May 2011
    Rep Power

    Default searching for a word in a string

    Hi guys,

    I have a project to do and i am very new to java. i need to search for a word or couple of words in a string and print out the characters that come after this word till the next empty line.

    for example we give : "meets the back."

    and the string would be:

    "The height of horses is measured at the highest point of the withers, where the neck meets the back.

    The English-speaking world measures the height of horses in hands (abbreviated "h" or "hh", for "hands high") and inches. One hand is equal to 101.6 millimetres.

    The general rule for height between a horse and a pony at maturity is 14.2 hands (58 inches, 147 cm). An animal 14.2 h or over is usually considered to be a horse and one less than 14.2 h a pony.

    it should print out the red lines shown.

    any help would be appreciated.
    Last edited by Brian-82; 05-11-2011 at 07:13 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    Have a look at the indexOf( ... ) method in the String class.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Replies: 1
    Last Post: 04-04-2011, 12:51 PM
  2. Searching for a String within an linked list
    By phil128 in forum Advanced Java
    Replies: 5
    Last Post: 04-13-2009, 02:18 AM
  3. [SOLVED] Searching a string in a vector
    By coolFrenzi in forum Advanced Java
    Replies: 5
    Last Post: 02-22-2009, 12:53 AM
  4. Searching In a String Array - Problem
    By DillMan in forum New To Java
    Replies: 4
    Last Post: 12-07-2008, 09:12 PM
  5. Searching a String from Text file using Swings .
    By in forum AWT / Swing
    Replies: 4
    Last Post: 09-09-2008, 05:29 AM

Posting Permissions

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