Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在提取到数组中时,我无法从文本文件中删除多个空格和制表符。
这是我所做的:
arrayofpara = bufdocument.split("[\\r\\n]+\\s");
让我知道上面的代码有什么问题?
谢谢!
你到底想做什么?
现在您拆分一系列“换行符”字符,后跟一个空白字符。我猜你想删除所有以下(和前面的?)空白字符。然后你需要给空白字符添加一个量词:
尝试
arrayofpara = bufdocument.split("\\s*[\\r\\n]+\\s*");
这也会在换行符上拆分,这些换行符后面没有空格字符,因为\\s*将匹配 0 个或多个空格。
\\s*