更新时间:2023-09-02 17:46:46
***使用Jackson映射器之类的JSON解析器来解析JSON字符串.
It is better to use a JSON parser like Jackson Mapper to parse a JSON String.
但是,如果您有一个简单的String,则可以快速使用示例正则表达式.
But to if you have a simple String you can use a sample Regular expression to it quickly.
尝试一下:
String str = "[\"String1\", \"String2\", \"oneMoreString\"]";
Pattern pattern = Pattern.compile("\"(.+?)\"");
Matcher matcher = pattern.matcher(str);
List<String> list = new ArrayList<String>();
while (matcher.find()) {
// System.out.println(matcher.group(1));.
list.add(matcher.group(1));
}