static boolean matchStr(String str, String pat, String matches[]) {
        int i = 0;      //  move through str
        int j = 0;      //  move through matches
        int pos = 0;    //  move through pat
   //   System.out.println("Inside matchStr :\n");
   //   System.out.print("Strlen of str,pat,match="+str.length()+pat.length()+matches.length+"\n");
   
        while (pos < pat.length() && j < matches.length) {
            char p = pat.charAt(pos);
           // System.out.println("p="+p+"\n");
            if (p == '*') 
            {
           //    System.out.println("p==*");
                int n;
                if (pos+1 == pat.length()) {
                    //  * is the last thing in pat
                    //  n is remaining string length
           
                    n = str.length() - i;
               //     System.out.println("n="+n+"\n");
                } else {
                    //  * is not last in pat
                    //  find using remaining pat
                  //    System.out.println("* is NOT the last thing in pat");
             //      System.out.println("Str.substring="+str.substring(i)+" "+pat.substring(pos+1));
             //       System.out.println("Before executing pat\n");
                    n = findPat(str.substring(i), pat.substring(pos+1)); // Number of characters common in str and pattern
       //            
        //            System.out.println("After executing findPat function n=:"+n+"\n");
                }
                if (n < 0) return false; //if -1 is returned
        
                String temp=str.substring(i, i+n); 
        
           
                matches[j++] = temp; //eg reasmb:is stored in matches
        
                i += n; pos++;  //
            } 
            else if (p == '#') 
            {
                int n = findNum(str.substring(i));
                matches[j++] = str.substring(i, i+n);
                i += n; pos++; 
            } 
            else {
             
                int n = amatch(str.substring(i), pat.substring(pos));
           
                if (n <= 0) return false;
                i += n; pos += n;
              
            }
        }
        if (i >= str.length() && pos >= pat.length()) return true;
        return false;
    }