How can I de-duplicate repeated characters in a Java string? -



How can I de-duplicate repeated characters in a Java string? -

does there exist method in java lets transform string how________are_______you how_are_you, i.e. maintain 1 _ when duplicated.

use regexp replacer:

string.replaceall("_+", "_"))

java string

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -