Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By Junky

Thread: Get characters between specific elements in string

  1. #1
    hacikho is offline Member
    Join Date
    Sep 2009
    Posts
    35
    Rep Power
    0

    Default Get characters between specific elements in string

    Hello,
    I have string values that I get from user such as "AD->C,AB->DF,B->C" , is there any way to get only the characters between > and , and adding them into array? On my example I want to have string array contains CDFC? How can I accomplish this?

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Get characters between specific elements in string

    You could probably use a regex to achieve this. Or you could get the index of ">", get the index of "," and substring between the two. Repeat. Then there is the special case for the last element at the end of the String.

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

    Default Re: Get characters between specific elements in string

    regex with look behind and look ahead should easily solve this.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Get characters between specific elements in string

    Fubarable likes this.

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

    Default Re: Get characters between specific elements in string

    Quote Originally Posted by Junky View Post
    Ah thanks. He's probably posted this in multiple forums and likely has received a complete answer in one of them, so no need for us to waste our time on this question.

  6. #6
    hacikho is offline Member
    Join Date
    Sep 2009
    Posts
    35
    Rep Power
    0

    Default Re: Get characters between specific elements in string

    thanks for helping, I just looked at forum today for answer and solved my problem. You are write it is dupliced post, in order to access more helpful people I used two different java forum. But I did not know whether this is againts forum rules, and procedures or not

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

    Default Re: Get characters between specific elements in string

    Multi-posting is not against the rules per se, but it is good etiquette to let all posts know about all the others. Since we are all volunteers helping in our free time, we appreciate it if you are considerate of our time and provide links to all multiposts so we can see them and not try to waste time duplicating that which has already been discussed elsewhere.

Similar Threads

  1. Filereader finding specific characters
    By busdude in forum New To Java
    Replies: 2
    Last Post: 09-29-2011, 02:04 PM
  2. How to withdraw a specific from a String?
    By equal in forum New To Java
    Replies: 6
    Last Post: 05-29-2011, 09:02 PM
  3. No of a specific char in a string
    By alinaqvi90 in forum New To Java
    Replies: 13
    Last Post: 05-27-2010, 07:59 AM
  4. Get value of a String into elements of an Array.
    By mainy in forum New To Java
    Replies: 1
    Last Post: 08-01-2009, 09:17 PM
  5. Help printing specific ArrayList elements
    By CirKuT in forum New To Java
    Replies: 5
    Last Post: 02-03-2009, 12:24 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
  •