Package java.util.regex

Examples of java.util.regex.Matcher.reset()


       String result = text;
       while (m.find())
       {
         String replacement = "<span class=\"highlight\">" + m.group().substring(1, m.group().length() - 1) + "</span>";
         result = m.replaceFirst(replacement);
         m.reset(result);
       }      
       return result;
    }
   
    private String escape(String value)
View Full Code Here


       String result = text;
       while (m.find())
       {
         String replacement = "<del>" + m.group().substring(1, m.group().length() - 1) + "</del>";
         result = m.replaceFirst(replacement);
         m.reset(result);
       }      
       return result;
    }
   
    private String parseLiteral(String text)
View Full Code Here

       String result = text;
       while (m.find())
       {
         String replacement = "<span class=\"literal\">" + m.group().substring(1, m.group().length() - 1) + "</span>";
         result = m.replaceFirst(replacement);
         m.reset(result);
       }      
       return result;      
    }

    private void writeUnmatched(OutputStream out) throws IOException {
View Full Code Here

      }
      line = val.toString();
      if (line.length() > 0 && line.charAt(line.length() - 1) == '\r') {
        line = line.substring(0, line.length() - 1);
      }
      matcher = matcher.reset(line);
      ArrayList<DataByteArray> list = new ArrayList<DataByteArray>();
      if (matcher.find()) {
        tryNext=false;
        for (int i = 1; i <= matcher.groupCount(); i++) {
          list.add(new DataByteArray(matcher.group(i)));
View Full Code Here

      return null;
    }
    Matcher match = varPat.matcher("");
    String eval = expr;
    for(int s=0; s<MAX_SUBST; s++) {
      match.reset(eval);
      if (!match.find()) {
        return eval;
      }
      String var = match.group();
      var = var.substring(2, var.length()-1); // remove ${ .. }
View Full Code Here

        Matcher matcher = null;
        for (String appPath : unfilteredAppPaths) {
            if (matcher == null) {
                matcher = filter.matcher(appPath);
            } else {
                matcher.reset(appPath);
            }
            if (matcher.matches()) {
                if (log.isDebugEnabled()) {
                    log.debug(sm.getString("hostConfig.ignorePath", appPath));
                }
View Full Code Here

        Matcher equiv = HTTP_META_PATTERN.matcher(head);
        Matcher charsetMatcher = FLEXIBLE_CHARSET_ATTR_PATTERN.matcher("");
        //iterate through meta tags
        while (equiv.find()) {
           String attrs = equiv.group(1);
           charsetMatcher.reset(attrs);
           //iterate through charset= and return the first match
           //that is valid
           while (charsetMatcher.find()){
              String candCharset = charsetMatcher.group(1);
              if (CharsetUtils.isSupported(candCharset)){
View Full Code Here

    assertEquals(4, matcher.start());
    if (found) {
      // modify text
      text.delete(0, text.length());
      text.append("Text have been changed.");
            matcher.reset(text);
    }

    found = matcher.find();
    assertFalse(found);
  }
View Full Code Here

      assertEquals(0, m.start());
      assertEquals(3, m.end());
      assertFalse(m.find());

      // Note: also testing reset here
      m.reset();
      assertTrue(m.find());
      assertEquals(0, m.start());
      assertEquals(3, m.end());
      assertFalse(m.find());
View Full Code Here

      assertTrue(m.find());
      assertEquals(0, m.start());
      assertEquals(3, m.end());
      assertFalse(m.find());

      m.reset("barfoobar");
      assertTrue(m.find());
      assertEquals(3, m.start());
      assertEquals(6, m.end());
      assertFalse(m.find());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.