我有一个字符串:
This is a test sentence 1.
This is a test sentence 2.
This is a test sentence 3.
This is a test sentence 4.
This is a test sentence 5.
我想用单行替换双行间隙。如:
This is a test sentence 1.
This is a test sentence 2.
This is a test sentence 3.
This is a test sentence 4.
This is a test sentence 5.
但是,我不知道如何检测双换行符,“\n”在替换单换行符时有效,但我在替换函数中尝试了“\n\n”但没有成功。
textView.setText(string.replaceAll("\n\n","\n"));
最佳答案
关于java - 如何在 Android 中将字符串中的双行替换为单行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25149579/