How to remove multiple line breaks from a string

前端 未结 1 881
礼貌的吻别
礼貌的吻别 2021-01-19 12:22

given a string i need to check if there are multiple line breaks (\\n). If there are i need to convert them to one single line break.

Can you please show me code th

相关标签:
1条回答
  • 2021-01-19 12:57

    try this

    s = s.replaceAll("(\r?\n){2,}", "$1");
    
    0 讨论(0)
提交回复
热议问题