I would like to parse just one long line from file based on " and , and [ and ] and { and }
For eg
{"ColumnTypes":"int32","fstring32","int32"],"ColumnNames":"ProductId",","ProductName","Quantity"]}
I actually need two different array from this line column types and column names. I tried string.split("\\\\W")
but it is not working.
Please guide. Thanks in advance.
你需要拆分多个 \\\\W
字符(添加一个+
),但首先从前面剪掉这些字符,这样你就不会得到一个空白的第一个元素:
String[] array = string.replaceAll("^\\W+", "").split("\\W+");
最简单的方法(使用正则表达式)将允许多个非单词字符匹配:
string.split("\\W+")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.