请问怎么区分
hello word
和
"hello word";
这两个对应的正则是什么
我例子没举好,是这样的 要怎么区分 “字母(可能有空格,下划线,汉字)" 和 没有引号的 字母(可能有空格,下划线,汉字)
好吧,是要怎么区分下面这两个字符串,我试了caozhy的方法好像有点问题
// String line = "\"string\": Hello World,";
String line = "\"string\": \"Hello World\",";
Matcher m = Pattern.compile("\"(.*)\"*\:\s?\"\w+\"\s?,?").matcher(line);
// Matcher m = Pattern.compile("\"(.*)\"*\:\s?\w+\s?,?").matcher(line);
System.out.println(m.matches());
m.reset();
while (m.find()) {
System.out.println(m.group());
}