Results 1 to 2 of 2
  1. #1
    ssk2659 is offline Member
    Join Date
    Jan 2015
    Rep Power

    Default Splitting a sentence

    hello! I'd just like to know how to split and then represent the splitted sentence.
    Suppose I have:

    Java Code:
    String sentence = "I Love my mother <=> I Love my father";
    String[] array = sentence.split("->");
    But how can I get now the lefthandside String values which is "I love my mother" and righthandside "I love my father"?
    I tried smth like:
    Java Code:
    String[] leftHandSide = array[0].split(" ");
    String[] rightHandSide = array[1].split(" ");
    But it's not working - getting error.

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

    Default Re: Splitting a sentence

    Check how sentence.indexOf("<=>") can be of any help. (hint: read the API docs for the String class).

    kind regards,

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

Similar Threads

  1. Need XML splitting
    By Tharun Jay in forum XML
    Replies: 2
    Last Post: 05-19-2014, 04:28 AM
  2. Splitting Strings
    By punk in forum New To Java
    Replies: 3
    Last Post: 04-06-2011, 08:49 AM
  3. Splitting
    By marksey07 in forum New To Java
    Replies: 2
    Last Post: 01-05-2011, 01:55 AM
  4. String Splitting
    By A.M.S in forum New To Java
    Replies: 1
    Last Post: 12-04-2009, 07:17 AM

Tags for this Thread

Posting Permissions

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