public static RegularExpression createRegex(String pattern,String options) throws ParseException {
  RegularExpression re=null;
  int intOptions=REUtil.parseOptions(options);
synchronized (REUtil.regexCache) {
    int i;
    for (i=0; i < REUtil.CACHESIZE; i++) {
      RegularExpression cached=REUtil.regexCache[i];
      if (cached == null) {
        i=-1;
        break;
      }
      if (cached.equals(pattern,intOptions)) {
        re=cached;
        break;
      }
    }
    if (re != null) {
      if (i != 0) {
        System.arraycopy(REUtil.regexCache,0,REUtil.regexCache,1,i);
        REUtil.regexCache[0]=re;
      }
    }
 else {
      re=new RegularExpression(pattern,options);
      System.arraycopy(REUtil.regexCache,0,REUtil.regexCache,1,REUtil.CACHESIZE - 1);
      REUtil.regexCache[0]=re;
    }
  }
  return re;
}

public static RegularExpression createRegex ( String pattern , String options ) throws ParseException { RegularExpression re = null ; int intOptions = REUtil . parseOptions ( options ) ; synchronized ( REUtil . regexCache ) { int i ; for ( i = 0 ; i < REUtil . CACHESIZE ; i ++ ) { RegularExpression cached = REUtil . regexCache [ i ] ; if ( cached == null ) { i = - 1 ; break ; } if ( cached . equals ( pattern , intOptions ) ) { re = cached ; break ; } } if ( re != null ) { if ( i != 0 ) { System . arraycopy ( REUtil . regexCache , 0 , REUtil . regexCache , 1 , i ) ; REUtil . regexCache [ 0 ] = re ; } } else { re = new RegularExpression ( pattern , options ) ; System . arraycopy ( REUtil . regexCache , 0 , REUtil . regexCache , 1 , REUtil . CACHESIZE - 1 ) ; REUtil . regexCache [ 0 ] = re ; } } return re ; }
creates a regularexpression instance . this method caches created instances .
