public boolean shExpMatch(String str,String shexp){
  StringTokenizer tokenizer=new StringTokenizer(shexp,"*");
  int startPos=0;
  while (tokenizer.hasMoreTokens()) {
    String token=tokenizer.nextToken();
    int temp=str.indexOf(token,startPos);
    if (startPos == 0 && !shexp.startsWith("*") && temp != 0) {
      return false;
    }
    if (!tokenizer.hasMoreTokens() && !shexp.endsWith("*") && !str.endsWith(token)) {
      return false;
    }
    if (temp == -1) {
      return false;
    }
 else {
      startPos=temp + token.length();
    }
  }
  return true;
}

public boolean shExpMatch ( String str , String shexp ) { StringTokenizer tokenizer = new StringTokenizer ( shexp , "*" ) ; int startPos = 0 ; while ( tokenizer . hasMoreTokens ( ) ) { String token = tokenizer . nextToken ( ) ; int temp = str . indexOf ( token , startPos ) ; if ( startPos == 0 && ! shexp . startsWith ( "*" ) && temp != 0 ) { return false ; } if ( ! tokenizer . hasMoreTokens ( ) && ! shexp . endsWith ( "*" ) && ! str . endsWith ( token ) ) { return false ; } if ( temp == - 1 ) { return false ; } else { startPos = temp + token . length ( ) ; } } return true ; }
returns true if the string matches the specified shell expression . actually , currently the patterns are shell expressions , not regular expressions .
