-1

The below code always print "no". Any ideas ?

import java.util.*;
import java.lang.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Rextester
{  
    public static void main(String args[])
    {
        String field= "superCategory(code)[composite={catalog: $catalog}]";

        Pattern FULL_PATTERN = Pattern
            .compile("\\[composite\\s*=\\s*\\{([^)]+)\\}\\]");

        final Matcher matcher = FULL_PATTERN.matcher(field);
        if (matcher.matches()) {
          System.out.println("yes");
        } else {
          System.out.println("no");

        }
    }
}
Saurabh Kumar
  • 16,353
  • 49
  • 133
  • 212

1 Answers1

0

You should find the pattern, not matches:

if (matcher.find()) {
Gábor Bakos
  • 8,982
  • 52
  • 35
  • 52