-1
我需要解析html字符串。我有這樣的文字從字符串中刪除' t'和' n'
<html> <head> </head> <body> <p style="margin-top: 0"> blbibibluboiubiubiu ibiub </p> </body></html>
我已經刪除了'\ n'個字符。現在我需要刪除'\ t'字符。我試圖這樣做
String s = editor.getText();
s = s.replaceAll("\\n", "");
s = s.replaceAll("\\t", "");
但它不起作用。請幫忙
您雙重轉義了您的轉義序列。用'「[\ t \ n]」'使用單個呼叫。投票結束爲錯字。 – dasblinkenlight
這應該起作用,是什麼讓你覺得它沒有?但是,請注意,您不需要使用'replaceAll'(它接受正則表達式),使用'.replace(「\ n」,「」)和'.replace(「\ t 「,」「)'。 –
你是否確定空格是製表符而不是空格? – Jens