我嘗試在文本文件中查找特定字符串。 該文件看起來像這樣:在文本文件中查找字符串
2,1,'Ausbau der techn。原基」
2,2, '拓德裝置技術'
2,3, 'Estensione阿爾istallazioni tecniche'
我試圖找到之間的文本'的跡象。
//Will be set automaticly after implementation.
int project = 2
int languageInteger = 1
String findings = new File(usedPath)?.eachLine {
it.substring((project+ ", " + languageInteger + ", "))
}
這是行不通的。我也試過用FindAll Closure或find。但我犯了一些錯誤。
我應該怎麼做才能找到文本?
這篇文章解釋[如何獲得引號之間的字符串數據(http://stackoverflow.com/questions/1473155/how-to-get-data-between-quotes-in-java)。你必須用正則表達式替換正則表達式中的'''' – Kaadzia
不,我知道「ist not' 我在下面的解決方案中做了一個replaceAll(」'「,」「),它工作正常現在。 – CollinG
我的意思是如果你打算使用教程中的正則表達式:'Pattern.compile(「\」([^ \「] *)\」「);''你必須替換'''' - ) – Kaadzia