Examples of groupCount()


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

  public void test() {
    String clause = "<#include \"/template/head.ftl\"/>";
    Pattern pattern = Pattern.compile("<#(.*)/>");
    Matcher m = pattern.matcher(clause);
    System.out.println(m.find());
    System.out.println(m.groupCount());
    System.out.println(Pattern.matches("<#(.*)/>", clause));
    System.out.println(m.group(1));
    StringBuffer sb = new StringBuffer();
    m.appendReplacement(sb, "[#$1/]");
    System.out.println(sb);
View Full Code Here

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

    // \b(\w+)\s?[,]?\s?(\w+)\s?[,]?\s?(\w+)\b
    // WORD SPACE , SPACE WORD SPACE , SPACE WORD
    // tested using http://www.javaregex.com/test.html
    Pattern p = Pattern.compile("\\b(\\w+)\\s*[,]?\\s*(\\w+)\\s*[,]?\\s*(\\w+)\\b");
    Matcher m = p.matcher(address);
    if (m.matches() && m.groupCount()>3)
    {
      addField(d, parent,"City",m.group(1));
      addField(d, parent,"StateProvince",m.group(2));
      addField(d, parent,"CountryRegion",m.group(3));
    }
View Full Code Here

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

    // (\d{1,2})\s?[.,-/]\s?(\d{1,2})\s?[.,-/]\s?(\d{2,4})
    // 1-2 DIGITS SPACE SEPERATOR SPACE 1-2 DIGITS SPACE SEPERATOR SPACE 2-4 DIGITS
    // tested using http://www.javaregex.com/test.html
    Pattern p = Pattern.compile("(\\d{1,2})\\s*[.,-/]\\s*(\\d{1,2})\\s*[.,-/]\\s*(\\d{2,4})");
    Matcher m = p.matcher(date);
    if (m.matches() && m.groupCount()>3)
    {
      addField(d, parent,"Month"+extra,m.group(1));
      addField(d, parent,"Day"+extra,m.group(2));
      addField(d, parent,"Year"+extra,m.group(3));
    }
View Full Code Here

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

                    sec_title = sec_title.replaceAll("IEEE Std ", "");
                  }
                  entry.setField(sourceField, sec_title);
                 
                }
                if (field.equals("pages") && fieldMatcher.groupCount() == 2) {
                  entry.setField(field, fieldMatcher.group(1) + "-" + fieldMatcher.group(2));
                }
              }
            }
            if (entry.getType() == BibtexEntryType.getStandardType("inproceedings") && entry.getField("author").equals("")) {
View Full Code Here

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

        String v = _pr.getJabrefVersion();
        Pattern p = Pattern.compile("([0-9]+)\\.([0-9]+).*");
        Matcher m = p.matcher(v);
        if (!m.matches())
            return;
        if (m.groupCount() >= 2) {
            _pr.setJabrefMajorVersion(Integer.parseInt(m.group(1)));
            _pr.setJabrefMinorVersion(Integer.parseInt(m.group(2)));
        }
    }
}
View Full Code Here

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

          list.add(new Cover(matcher.group(2), matcher.group(1), new URL(bestUrl)));
        } catch(IOException e) {
          //Do not add the cover since we got an exception
        }

        nextSubIndex += matcher.end(matcher.groupCount());
      } else {
        break;
      }
    }
    return list;
View Full Code Here

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

    public void postProcess(ClassLoader classLoader) {
        for (FileDescriptor fileDescriptor : getResources())
        {
            Matcher matcher = compiledPattern.matcher(fileDescriptor.getName());
            if (matcher.matches()) {
                String[] groups = new String[matcher.groupCount()];
                for (int i = 0; i < groups.length; i++) {
                   groups[i] = matcher.group(i+1);
                }
                if (groups == null || groups.length != 3) {
                    throw new InvalidWikiConfigurationException("Deployment of i18n properties failed");
View Full Code Here

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

        if (this.secretToken == null) {
            String body = null;
            try {
                body = new String(doPostAsAdmin("Main", "WebHome", null, "edit", "editor=wiki", null).getResponseBody(), "UTF-8");
                Matcher matcher = Pattern.compile("<input[^>]+form_token[^>]+value=('|\")([^'\"]+)").matcher(body);
                if (matcher.find() && matcher.groupCount() == 2) {
                    this.secretToken = matcher.group(2);
                    return this.secretToken;
                }
            } catch (IOException exception) {
                exception.printStackTrace();
View Full Code Here

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

            String url = createUrl("edit", "Main", "WebHome", null);
            BufferedReader reader = new BufferedReader(new InputStreamReader(AbstractEscapingTest.getUrlContent(url)));
            String line;
            while ((line = reader.readLine()) != null) {
                Matcher matcher = pattern.matcher(line);
                if (matcher.find() && matcher.groupCount() == 2) {
                    return matcher.group(2);
                }
            }
        } catch (IOException exception) {
            exception.printStackTrace();
View Full Code Here

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

        try {
            String line;
            while ((line = data.readLine()) != null) {
                Matcher match = pattern.matcher(line);
                while (match.find()) {
                    for (int i = 1; i <= match.groupCount(); i++) {
                        String parameter = match.group(i);
                        if (parameter != null && !parameter.matches("\\s*") && !ignored.contains(parameter)) {
                            input.add(parameter);
                        }
                    }
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.