Results 1 to 4 of 4
  1. #1
    tontondp21 is offline Member
    Join Date
    Mar 2017
    Posts
    1
    Rep Power
    0

    Default How to minimize a string result in java

    I want to minimize this string "AHHHAAAAARTFUHLAAAAAHV" to "AHHHAARTFUHLAHV". Removing excessive "A's" would be my only option. I tried using a split function (with a delimiter of "AAAA[^A]") to make it look like this [AHHHA, AAAA, RTFUHLAA, AAAA, HV]. But now im at lost how to manipulate those indices with "AAAA"s now to arrive to my desired output.

    XML Code:
    String y = "AHHHAAAAARTFUHLAAAAAAHV";
      String x = "AHHHAARTFUHLAHV"; //desired match or output
     
      String [] test = y.split("(?=AAAA[^A]|(?<=AAAA(?=[^A])))");

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: How to minimize a string result in java

    Can you provide a more general description of what you want? Excessive A's doesn't tell me anything because I don't know what excessive means. You have one A at the beginning, one near the end and two together in the middle of your desired output. So describe what you want in words, then provide a couple of examples.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: How to minimize a string result in java

    Removing excessive "A's"
    Can you explain what an excessive "A" is?
    I see "AA" in the middle of the desired output.
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: How to minimize a string result in java

    Last edited by Norm; 03-22-2017 at 11:53 PM.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Java Result: 1
    By mharsijamel in forum New To Java
    Replies: 3
    Last Post: 01-09-2013, 08:01 PM
  2. Struts 2 error : No result defined for action / result
    By sameerk in forum Web Frameworks
    Replies: 1
    Last Post: 05-17-2011, 10:15 AM
  3. Java Result: 255
    By MadJack in forum New To Java
    Replies: 14
    Last Post: 11-11-2010, 08:54 AM
  4. Replies: 4
    Last Post: 08-19-2010, 01:06 AM
  5. Help!! how to turn query result to string
    By stefanybaez in forum Advanced Java
    Replies: 2
    Last Post: 12-11-2008, 11:42 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
  •