我想用','运算符拆分字符串。原始字符串如下所示
input : decode(test,0,nvl(test,0),1)
My expected output:
decode(test
0
nvl(test,0)
1
我尝试了以下程序
String input = "decode(test,0,nvl(test,0),1)";
String[] arr = input.split(",");
帮我解决上述问题
答案 0 :(得分:3)
试试这个
String arr[ ]= "decode(test,0,nvl(test,0),1)".split ("nvl\\(test,0\\)");
结果
arr[0] == "decode(test,0,"
arr[1] == "nvl(test,0)"
arr[2] == ,1
现在使用arr[0]
arr[2]
和split(",");