Remove doubled letter from a string using java

后端 未结 4 746
孤独总比滥情好
孤独总比滥情好 2021-01-18 20:06

I need to remove a doubled letter from a string using regex operations in java. Eg: PRINCEE -> PRINCE APPLE -> APLE

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-18 20:21

    String s = "...";
    String replaced = s.replaceAll( "([A-Z])\\1", "$1" );
    

提交回复
热议问题