Regex to match string inside square brackets

Use the following regex to match a string inside square brackets.

public static void main(String[] args)
        {
                String regex = "^\\[(.*?)\\]";

                Pattern p = Pattern.compile(regex);
               
               

             
              Matcher m = p.matcher("[m04z1] Mobile Computing Case Study Description");
              if (m.find()) {
                 
                  System.out.println("group -> "+m.group());
                 
              }else {
                  System.out.println("NO MATCH FOUND");
              }
        }

Search