Package org.apache.xerces.impl.xpath.regex

Examples of org.apache.xerces.impl.xpath.regex.Match


    String s = content;
    final RegularExpression regexPattern = makePatternXerces(pattern, flags);
    if (regexPattern == null)
      return s;
    else {
      Match m = new Match();
      if(regexPattern.matches(s,m)){
        String result = "";
        while(regexPattern.matches(s,m)){
          int numberOfGroups = m.getNumberOfGroups();
          if(numberOfGroups>0){
            String interReplacement = new String(replacement);
            if(numberOfGroups>1){
              for(int i=numberOfGroups-1; i>0; i--){ // start at the end to not have problems that $1 is replaced for a string $10 but $10 should be replaced (the same leading prefixes!)
                int start = m.getBeginning(i);
                int end = m.getEnd(i);               
                String r = (start>=0 && end>=0)?s.substring(start, end):"";
                interReplacement=interReplacement.replaceFirst("[$]"+i, r);
              }
            }
            result+=s.substring(0, m.getBeginning(0))+interReplacement;
            s=s.substring(m.getEnd(0));
          }
        }
        return result+s;
      } else return s;
    }
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.xpath.regex.Match

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.