I need to remove all redundant hyphens in a given string, e.g.: "Bla----Bla---Bla--Bla" to "Bla-Bla-Bla-Bla", using as little code as possible.
At the moment I've implemented this:
url = url.replace('----', '-');
url = url.replace('---', '-');
url = url.replace('--', '-');
to achieve this.
Is there a way to use the String.replaceAll method to achieve this?
Thank You!