Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Finding all the contents of the string after a specified letter

  1. #1
    rokit boy is offline Member
    Join Date
    Feb 2012
    Posts
    35
    Rep Power
    0

    Default Finding all the contents of the string after a specified letter

    I have a string called A and it's contents are "Hello|Hi"
    I have another string called B, and I want it so it's contents are "Hi"
    Is this possible?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Finding all the contents of the string after a specified letter

    Quote Originally Posted by rokit boy View Post
    I have a string called A and it's contents are "Hello|Hi"
    I have another string called B, and I want it so it's contents are "Hi"
    Is this possible?
    Sure, use replaceAll(...) with regular expressions:

    Java Code:
          String pre = "Hello|Hi";
          String post = pre.replaceAll(".*\\|", "");
          System.out.println(post);
    rokit boy likes this.

  3. #3
    rokit boy is offline Member
    Join Date
    Feb 2012
    Posts
    35
    Rep Power
    0

    Default Re: Finding all the contents of the string after a specified letter

    Figured it out. Nearly exact same as your solution :D
    Thank you.

Similar Threads

  1. Replies: 1
    Last Post: 02-26-2012, 07:10 AM
  2. frequency of occurence of a letter in a string
    By manish007g in forum New To Java
    Replies: 4
    Last Post: 06-23-2011, 09:05 PM
  3. Checking The Contents of a String
    By jayragz in forum New To Java
    Replies: 7
    Last Post: 05-26-2011, 10:15 AM
  4. Replies: 5
    Last Post: 10-30-2010, 06:56 PM
  5. Replies: 20
    Last Post: 05-14-2008, 09:42 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
  •