我想用「SEK xx」/「SEK xx.xx」替換模式爲「xx kr」或「xx.xx kr」(其中x爲數字)的子字符串。使用正則表達式替換子字符串
例如:此產品成本34.55 KR =>該商品價格爲SEK 34.55
我已經開始在我的類中的方法:
/* Uses regex pattern to replace this pattern*/
private void replacePatternInLine(String line){
line = line.replaceAll("regex", "SEK");
System.out.println(line);
}
,但我不知道如果我在正確的軌道上。如果我有什麼正則表達式的幫助,我將不勝感激
我不是很清楚maby,但我從文件一次讀一行。所以格式是一個子字符串。 – Fanny