我有這樣如何從文本中刪除特定的重複字符?
"this is line 1\n\n\nthis is line 2\n\n\nthis is line 3\t\t\tthis is line 3 also"
一個字符串我想要做的就是刪除,如「\ n」,「\ t」的從這段文字重複特定的字符。
"this is line 1\nthis is line 2\nthis is line 3\tthis is line 3 also"
我嘗試了一些正則表達式,但沒有爲我工作。
text = text.replace("/[^\\w\\s]|(.)\\1/gi", "");
有沒有這樣的正則表達式?
@anubhava這是java。 – hellzone