Given the following Java codes:
String test = "'abc,ab,123',,,'123,aa,abc',,,";
Pattern p = Pattern.compile("('\\w\\S+\')");
Matcher m = p.matcher(test);
boolean s = m.matches();
System.out.println(s);
I want to extract all the content in '', for example I want 'abc,ab,123' and '123,aa,abc'. Why the outout is:
false
My regular expression is like: "find a ',followed by a number or a letter, followed by several non-space characters,followed by another '". It should have a match, what's wrong?
m.findinstead ofm.matches.'[^']*'regex to get the output you want.\\Swould also match'