Java Regex - reduce spaces in a string

前端 未结 4 1298
刺人心
刺人心 2020-12-16 00:42

I don\'t have time to get my head around regex and I need a quick answer. Platform is Java.

I need the string

\"Some text   with  spaces\"
<         


        
4条回答
  •  清酒与你
    2020-12-16 01:44

    For Java (not javascript, not php, not anyother):

    txt.replaceAll("\\p{javaSpaceChar}{2,}"," ")
    

提交回复
热议问题