Package java.util.regex

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


    while ((line = br.readLine()) != null) {
      if (p_comment.matcher(line).find()) {
        continue;
      }
      m = p_parameter.matcher(line);
      if (m.find() && (m.groupCount() == 6)) {
        GridParameter p = new GridParameter(Integer.parseInt(m.group(3)), m.group(4), m.group(6),
            m.group(5));
        getDiscipline(Integer.parseInt(m.group(1))).getCategory(
            Integer.parseInt(m.group(2))).setParameter(p);
      }
View Full Code Here


    byte[] bytearrayMessage = null;

    try {
      Matcher matcher = ImapToolkit.getMessagePattern().matcher(url);
      matcher.find();
      if( matcher.groupCount()>0 ) {
        // We found a message url. Determine the message UID from the url.
        int messageUID = Integer.parseInt(matcher.group(3));
        mLog.debug("Read mime message uid: " + messageUID + " for IMAP url: " + url);
        Session session = Session.getInstance(new Properties());
   
View Full Code Here

    if (mQueryText != null) {
      // Remove the mimetype field if the query contains it

      Matcher matcher = mimetypeFieldPattern.matcher(mQueryText);
      boolean found = matcher.find();
      if (found && matcher.groupCount() > 0) {
        // the first group is the mimetype field identifier
        mimeTypeFieldText = matcher.group(1);
        queryText = mQueryText.replace(mimeTypeFieldText, "");
        //System.out.println("Query after mimetype removing: " + queryText);
View Full Code Here

  public static String createURLWithoutPath(String completeUrl) throws RegainException {

    String result = "";
    Matcher matcher = urlPatternLeft.matcher(completeUrl);
    matcher.find();
    if (matcher.groupCount() > 0) {
      try {
        return matcher.group(1) + "/";
      } catch (IllegalStateException ex) {
        // No match found
        return "";
View Full Code Here

      throw new JavaSoundUrlParserException("Expected URL to start with: " + "javasound://");
    Matcher m = pattern.matcher(url);
    if (!m.matches())
      throw new JavaSoundUrlParserException("URL does not match regular expression for javasound URLs");
   
    int groupCount = m.groupCount();
   
    double rate = AudioFormat.NOT_SPECIFIED;
    int bits = AudioFormat.NOT_SPECIFIED;
    int channels = AudioFormat.NOT_SPECIFIED;
    int endian = AudioFormat.NOT_SPECIFIED;
View Full Code Here

        al.add(new FixedString(s.substring(i, m.start())));
    }

    // Expect 6 groups in regular expression
    String[] sa = new String[6];
    for (int j = 0; j < m.groupCount(); j++)
        {
        sa[j] = m.group(j + 1);
//         System.out.print(sa[j] + " ");
        }
//     System.out.println();
View Full Code Here

            // name based guess
            if (buddy.getUser().indexOf("@") == -1) {
                Pattern p = Pattern
                        .compile("^(aim|msn|yahoo|icq|gadu-gadu)[-_.].*");
                Matcher m = p.matcher(buddy.getUser());
                if (m.matches() && m.groupCount() >= 1) {
                    String type = m.group(1);
                    if (type != null) {
                        statusIcon = Standard
                                .getIcon("imagethemes/statusicons/"
                                        + type
View Full Code Here

     */
    public static String find(String self, Pattern pattern, Closure closure) {
        Matcher matcher = pattern.matcher(self);
        if (matcher.find()) {
            if (hasGroup(matcher)) {
                int count = matcher.groupCount();
                List groups = new ArrayList(count);
                for (int i = 0; i <= count; i++) {
                    groups.add(matcher.group(i));
                }
                return InvokerHelper.toString(closure.call(groups));
View Full Code Here

  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

    // \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

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.