我想从java中使用正则表达式从json对象中提取字符串。Java正则表达式不匹配
的字符串看起来是这样的:
{"key":"value"}
正则表达式的方法代码如下所示:
public String extractVal(String dataRaw) {
Pattern p = Pattern.compile(":\"(.+\b)");
Matcher m = p.matcher(dataRaw); //dataRaw is string from above^
if (m.matches()) {
return m.group(1);
}
return null;
}
它永远只是返回null。我做错了什么?
在此先感谢
为什么不简单地使用jsonparser或者什么 –
'我需要使用java中的正则表达式从json对象中提取一个字符串......不,您不需要使用JSON解析器。 –
我知道什么是JSON解析器,这不是我问的。 – Plays2