简体   繁体   中英

How to extract values inside brackets in a json string using Java Regex

I would like to use regex to extract the values used inside the second []

[
"Shoes for men wither",
"Shoes for men wither leather",
]

在此处输入图像描述

I have tried the following: check all the words between quotes.

 Matcher m = Pattern.compile("\"([^\"]*)\"").matcher(response);

The problem with the above is that it gives me the other values outside the inner array.

This looks like JSON, which is not a regular language , and thus can't be parsed reliably with regex. You would almost certainly be better off using a JSON parsing library, such as Gson or one of the many listed at json.org .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM