Find second occurrence of pattern in regex

Viewed 8809

my inputs is

  String t1 = "test1:testVar('varName', 'ns2:test')";
  String t2 = "test2:testVar('varName', 'ns2:test', 'defValue')";
  String patternString = "\('.*',\s*('.*:.*').*\)";

I try to capture only text between second pair of ' ', ie: ns2:test my pattern is : ('.',\s('.:.').*) and for first string it is ok,but for second i got as result: 'ns2:test', 'defValue'

2 Answers
Related