Package com.google.gwt.regexp.shared

Examples of com.google.gwt.regexp.shared.MatchResult


    private ArrayList<String> getTagList(String src) {
        final RegExp regExp = RegExp.compile(tagRegex, "g");

        ArrayList<String> list = new ArrayList<String>();
        MatchResult result = regExp.exec(src);
        while (result != null) {
            String node = result.getGroup(0);
            list.add(node);
            result = regExp.exec(src);
        }
        return list;
    }
View Full Code Here


    private List<String> listMissing(String compareFrom, String compareTo) {
        final RegExp regExp = RegExp.compile(tagRegex, "g");

        String tmp = compareTo;
        ArrayList<String> unmatched = new ArrayList<String>();
        MatchResult result = regExp.exec(compareFrom);

        while (result != null) {
            String node = result.getGroup(0);
            if (!tmp.contains(node)) {
                unmatched.add(node);
            } else {
                int index = tmp.indexOf(node);
                String beforeNode = tmp.substring(0, index);
View Full Code Here

        return errors;
    }

    private static boolean hasPosition(ArrayList<String> variables) {
        for (String testVar : variables) {
            MatchResult result = POSITIONAL_REG_EXP.exec(testVar);
            if (result != null) {
                return true;
            }
        }
        return false;
View Full Code Here

    private List<String> checkPosition(ArrayList<String> variables, int size) {
        ArrayList<String> errors = new ArrayList<String>();

        Multimap<Integer, String> posToVars = ArrayListMultimap.create();
        for (String testVar : variables) {
            MatchResult result =
                    PrintfXSIExtensionValidation.POSITIONAL_REG_EXP
                            .exec(testVar);
            if (result != null) {
                String positionAndDollar = result.getGroup(1);
                int position =
                        PrintfXSIExtensionValidation
                                .extractPositionIndex(positionAndDollar);
                if (position >= 0 && position < size) {
                    posToVars.put(position, testVar);
View Full Code Here

    protected ArrayList<String> findVars(String inString) {
        ArrayList<String> vars = new ArrayList<String>();
        // compile each time to reset index
        RegExp varRegExp = RegExp.compile(VAR_REGEX, GLOBAL_FLAG);
        MatchResult result = varRegExp.exec(inString);
        while (result != null) {
            vars.add(result.getGroup(0));
            result = varRegExp.exec(inString);
        }
        return vars;
    }
View Full Code Here

                o.get(MSGCTXT_KEY)
        );
    }

    private static Map<String, String> parseRecursive(String query, Map<String, String> accumulator) {
        MatchResult keyMatch = keyRegex.exec(query);

        String key, remainder;
        if (keyMatch != null) {
            key = keyMatch.getGroup(1);
            remainder = keyMatch.getGroup(2);
        } else {
            key = KEYS[DEFAULT_KEY];
            remainder = query;
        }

        MatchResult valMatch = valRegex.exec(remainder);
        String val, nextPart;
        if (valMatch != null) {
            val = valMatch.getGroup(1);
            nextPart = valMatch.getGroup(2);
        } else {
            val = remainder;
            nextPart = "";
        }

        if (KEYS_WITH_SINGLE_VALUE.contains(key)) {
            MatchResult wordMatch = leadingWordRegex.exec(val);
            if (wordMatch != null) {
                val = wordMatch.getGroup(1);
                String otherWords = wordMatch.getGroup(2);
                if (!Strings.isNullOrEmpty(otherWords.trim())) {
                    joinValue(accumulator, KEYS[DEFAULT_KEY], otherWords);
                }
            }
        }
View Full Code Here

        final String timeFrag = "((?:T| )(?:(?:[01][0-9]|2[0-3]):(?:[0-5][0-9]):(?:[0-5][0-9])(?:\\.[0-9]+)?|(?:24:00:00(?:\\.0+)?)))?"; // Group 2
        final String timeZoneFrag = "(Z|(?:\\+|-)(?:(?:0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"; // Group 3

        String pattern = "^" + yearMonthDayFrag + timeFrag + timeZoneFrag + "$";
        RegExp regExp = RegExp.compile(pattern);
        MatchResult matchResult = regExp.exec(lexicalValue);
        if(matchResult == null) {
            throw new IllegalArgumentException();
        }
        String matchedYearMonthDay = matchResult.getGroup(1);
        String matchedTime = matchResult.getGroup(2);
        String matchedTimeZone = matchResult.getGroup(3);

        String properLexicalValue = matchedYearMonthDay;
        if(matchedTime != null) {
            if (!matchedTime.startsWith("T")) {
                properLexicalValue += "T" + matchedTime.trim();
View Full Code Here

     * @param id The string to check.
     * @return The specified string.
     * @throws ProjectIdFormatException if the specified string does not match the UUID pattern.
     */
    private static String checkFormat(String id) throws ProjectIdFormatException {
        MatchResult result = PROJECT_ID_REG_EXP.exec(id);
        if(result == null) {
            throw new ProjectIdFormatException(id);
        }
        return id;
    }
View Full Code Here

        && url.contains(GOOD_URL_PREFIX)) {
      categoryKeyRegexp = CATEGORY_URL_PREFIX + "(.+)/good";

      RegExp goodRegexp = RegExp.compile(".+" + GOOD_URL_PREFIX
          + "(.+)/");
      MatchResult goodMatch = goodRegexp.exec(url);
      if (goodMatch == null) {
        showGoodUrlError();
        return;
      }
      final String goodKey = goodMatch.getGroup(1);
      //1
      callback = getRenderGoodCallback(goodKey);
    } else {
      showCategoryUrlError();
      return;
    }

    RegExp p = RegExp.compile(categoryKeyRegexp);
    MatchResult m = p.exec(url);
    if (m == null) {
      showNoCategoryUrlError(callback);
      return;
    }
    final String categoryKey = m.getGroup(1);
    //2
    renderCategory(callback, categoryKey);
  }
View Full Code Here

    String hyphenated = camelCaseMap.get(name);

    // Convert the name to hyphenated format if not in the cache.
    if (hyphenated == null) {
      hyphenated = "";
      MatchResult matches;
      while ((matches = camelCaseWord.exec(name)) != null) {
        String word = matches.getGroup(0);
        if (caseWord.exec(word) == null) {
          // The first letter is already lowercase, probably the first word.
          hyphenated += word;
        } else {
          // Hyphenate the first letter.
          hyphenated += "-" + StringCase.toLower(matches.getGroup(1));
          if (matches.getGroupCount() > 1) {
            hyphenated += matches.getGroup(2);
          }
        }
      }
      camelCaseMap.put(name, hyphenated);
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.regexp.shared.MatchResult

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.