我有一個包含字符串在此格式的文件:如何將一個字符串分解去除某些部分
ACHMU)][2:s,161,(ACH Payment Sys Menus - Online Services)][3:c,1,(M)][4:c,1,(N)]
ACLSICZ)][2:s,161,(Report for Auto Closure)][3:c,1,(U)][4:c,1,(N)]
ACMPS)][2:s,161,(Account Maintenance-Pre-shipment Account)][3:c,1,(U)][4:c,1,(N)]
ACNPAINT)][2:s,161,(Interest Run For NPA Accounts)][3:c,1,(U)][4:c,1,(N)]
我需要拆分字符串,使我在這個格式的數據:
ACHMU (ACH Payment Sys Menus - Online Services)
ACLSICZ (Report for Auto Closure)......
基本上,我想刪除「)[2:s,161,」部分和「] [3:c,1,(M)] [4:c,1,(N)]」結束。將字符串分割幫助我嗎?下面的方法已經失敗:
FileInputStream fs = new FileInputStream(C:/Test.txt);
BufferedReader br = new BufferedReader(new InputStreamReader(fs));
String str;
while((str = br.readLine()) != null){
String[] split = str.Split(")[2:s,161,")
}
請幫我弄到垃圾在中間和結束。
是那裏,你得到任何錯誤或異常後的String [] =分裂str.Split( 「)[2:S,161」)? – FSP 2012-07-05 11:44:42
沒有錯誤,只是字符串不能分割。 – ErrorNotFoundException 2012-07-05 11:45:53
使用正則表達式作爲nhahtdh提到。 – 2012-07-05 11:52:22