Given following Java expression codes:
boolean match = row.matches(\"(\'.*\')?,(\'.*\')?\");
if the match is true, it
You could try String[] groups = row.split(",");. Then you can use groups[0] and groups[1] to get each of the 'groups' you're looking for.
To access the groups you need to use Matcher: Pattern.compile(regex).matcher(row).
Then you can call find() or matches() on the matcher to execute the matcher and if they return true you can access the groups via group(1) and group(2).
String row = "'what','ever'";
Matcher matcher = Pattern.compile("('.*')?,('.*')?").matcher( row );
if( matcher.matches() )
{
String group1 = matcher.group( 1 );
String group2 = matcher.group( 2 );
}