Package sunlabs.brazil.util.regexp

Examples of sunlabs.brazil.util.regexp.Regexp


            if (!name.endsWith(".")) {
                this.name += ".";
      }
            this.exp=null;
            try {
         this.exp = new Regexp(exp, (flags.indexOf("I") != -1));
      } catch (IllegalArgumentException e) {
          System.out.println("Token " + name + ": \"" + exp +
      "\" Is not valid: " + e.getMessage());
    throw e;
      }
View Full Code Here


  if (glob) {
      bag.subspecs = MAX_MATCHES;
      bag.sub = new String[bag.subspecs + 1];
  } else {
      try {
    bag.r = new Regexp(pat);
      } catch (IllegalArgumentException e) {
    return false;
      }
      bag.subspecs = bag.r.subspecs();
      bag.sub = new String[bag.subspecs];
View Full Code Here

  if ((arg = hr.get("value")) != null) {
      result = arg.equals(value);
  } else if ((arg = hr.get("match")) != null) {
      boolean ignoreCase = hr.isTrue("nocase");
      try {
    result = (new Regexp(arg, ignoreCase).match(value) != null);
      } catch (IllegalArgumentException e) {}
  } else if ((arg = hr.get("glob")) != null) {
      result = Glob.match(arg, value);
  } else if (hr.isTrue("any")) {
      result=hr.request.props.propertyNames(name).hasMoreElements();
View Full Code Here

        props.put(prefix + s, sub[i]);
        matches++;
    }
      }
  } else if (match != null) {
      Regexp r;
      try {
    r = new Regexp(match, hr.isTrue("nocase"));
    String replace = hr.get("replace");
    boolean all = hr.isTrue("all");

    if (replace != null) {
        String result;
        if (all) {
            result = r.subAll(value, replace);
        } else {
            result = r.sub(value, replace);
        }
        props.put(prefix + "replace",
          result==null ? nullStr :result);
    } else {
       int subMatches = Math.min(MAX_MATCHES, r.subspecs());
       String[] sub = new String[subMatches];
       if (all) {    // all matches
           Regsub rs = new Regsub(r, value);
           StringBuffer counter = new StringBuffer();
           while(rs.nextMatch()) {
         matches++;
         props.put(prefix + matches, rs.matched());
         for (int i = 1; i < subMatches; i++) {
             String s = mapTable.length >= i ? mapTable[i-1] : "" + i;
             props.put(prefix + matches + "." + s,
               (rs.submatch(i)==null ? nullStr : rs.submatch(i)));
         }
         counter.append(matches + " ");
           }
           if (matches>0) {
         props.put(prefix + "submatches", "" + subMatches);
         props.put(prefix + "matchlist", counter.toString());
           }
       } else if (r.match(value, sub)) {  // first match
           for (int i = 0; i < sub.length; i++) {
         if (sub[i] == null) {
             sub[i] = "";
         }
         props.put(prefix + i, sub[i]);
View Full Code Here

  isMine = new MatchString(prefix, server.props);
  redirect = server.props.getProperty(prefix + REDIRECT);
  String str = server.props.getProperty(propsPrefix + "allow");
  if (str != null) {
     try {
       allow = new Regexp(str);
     } catch (Exception e) {
         server.log(Server.LOG_WARNING, prefix,
       "Invalid regular expression for \"allow\"");
         return false;
     }
        }
  str = server.props.getProperty(propsPrefix + "deny");
  if (str != null) {
     try {
       deny = new Regexp(str, true);
     } catch (Exception e) {
         server.log(Server.LOG_WARNING, prefix,
       "Invalid regular expression for \"deny\"");
         return false;
     }
View Full Code Here

TOP

Related Classes of sunlabs.brazil.util.regexp.Regexp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.