Package sunlabs.brazil.util.regexp

Examples of sunlabs.brazil.util.regexp.Regsub


     * values may be in "'s.
     */

    public static Properties extractAuth(String header) {
  Properties h = new Properties();
  Regsub rs = new Regsub(re, header);
  while (rs.nextMatch()) {
      String key = rs.submatch(1);
      String value = rs.submatch(4);
      if (value == null) {
    value = rs.submatch(2);
      }
      h.put(key.toLowerCase(), value);
  }
  // h.list(System.out);
  return h;
View Full Code Here


  public
  ReStringTokenizer(String str, String re)
  throws IllegalArgumentException {
      super(str, re);
      rs = new Regsub((new Regexp(re)), str);
  }
View Full Code Here

              } else {
      props.put(name + i, sub[i]);
        }
          }
      } else if (!single)  {
          Regsub rs = new Regsub(exp, data);
          while(rs.nextMatch()) {
        matches++;
        matchList.append(" " + matches);
        if (names != null) {
                  if (!names[0].equals("X")) {
          props.put(name + matches + "." + names[0],
            rs.matched());
      }
        } else {
      props.put(name + matches, rs.matched());
        }

        // use sub-match as an index instead of a number

        String otherKey = null;
        if (subIndex > 0 && subIndex < subMatches) {
      otherKey =  rs.submatch(subIndex);
        }
        if (otherKey == null) {
      otherKey = "" + matches;
        }
        for (int i = 1; i < subMatches; i++) {
            String key;
      if (names != null && names.length > i) {
          if (names[i].equals("X")) {
              continue;
          }
                key = name + otherKey + "." + names[i];
      } else {
                key = name + otherKey + "." + i;
      }
            props.put(key,
           (rs.submatch(i)==null ? nullStr : rs.submatch(i)));
          }
          }
      }
      ok =  (matches > 0);
      props.put(name + "matches", matchList.toString());
View Full Code Here

  boolean reverse = hr.isTrue("reverse");

  if ((sort == null) && (reverse == false)) {
      while (st.hasMoreTokens()) {
    if (isRe) {  // previous token
       Regsub rs = ((ReStringTokenizer)st).getRs();
       String matched = rs.matched();
       if (matched != null) {
           local.push(name + ".delim", matched);
           int subs = rs.getRegexp().subspecs();
           for(int i=1; i<subs;i++) {
          String sub = rs.submatch(i);
          if (sub != null) {
        local.push(name + ".delim." + i, sub);
          }
           }
       }
View Full Code Here

          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);
View Full Code Here

TOP

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

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.