• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to minimize a string result in java

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
author
Posts: 23836
140
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You need to better explain the rules. Why does five "A"s become two "A"s? and why does six "A"s become one "A"? And what about other amounts of excess "A"s?

Henry
 
Henry Wong
author
Posts: 23836
140
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Norm. Have a cow...


To the OP, cross-posting *is* allowed on the ranch. It is not against the rules. However, we would like you to follow some guidelines, so that you don't waste the time and/or effort of your fellow ranchers. Please see this...

https://coderanch.com/wiki/660346/Forthright-Cross-Posting-Sites

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!