Remove all non-“word characters” from a String in Java, leaving accented characters?

后端 未结 5 1249
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 02:18

Apparently Java\'s Regex flavor counts Umlauts and other special characters as non-\"word characters\" when I use Regex.

        \"TESTÜTEST\".replaceAll( \"         


        
5条回答
  •  爱一瞬间的悲伤
    2020-11-28 02:55

    Well, here is one solution I ended up with, but I hope there's a more elegant one...

    StringBuilder result = new StringBuilder();
    for(int i=0; i

    result ends up with the desired result...

提交回复
热议问题