Package java.util.regex

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


    while( line != null )
    {
      if (line.trim().length() > 0 && usefulData.matcher(line).lookingAt())
      {// we are here if the line is non-empty and contains the magic keyword
        Matcher lexer = pat.matcher(line);
        if (!lexer.lookingAt() || lexer.group(GROUP_TEXT) == null)
          throwEx(line);
        //for(int i=1;i<=lexer.groupCount();++i)
        //  System.out.println("("+i+") "+lexer.group(i));
        String text = "["+lexer.group(GROUP_TEXT)+"]";
        if (lexer.group(GROUP_YES) != null)
View Full Code Here


  public static Pattern regex(final java.util.regex.Pattern p) {
    return new Pattern() {
      @Override public int match(CharSequence src, int begin, int end) {
        if (begin > end) return Pattern.MISMATCH;
        Matcher matcher = p.matcher(src.subSequence(begin, end));
        if (matcher.lookingAt()) return matcher.end();
        return Pattern.MISMATCH;
      }
    };
  }
 
View Full Code Here

        if(m.matches()) {
          return i;
        }
       
        m = suffixPrefixPattern.matcher(suffix);
        if(m.lookingAt()) {
          suffix = suffix.substring(m.end());
        }
        while(suffix.length() >= 3) {
          if(splitSuffixes.contains(suffix)) {
            //if(!wouldTok) System.out.printf("%s %d\n", s, i);
View Full Code Here

    String rep = s;
    // if starts with a non a-z or A_Z

    Matcher m_ = p_.matcher(rep);

    if (m_.lookingAt()) {
      rep = "_" + rep;
    }
    return rep;

  }
View Full Code Here

      countryCode = maybeExtractCountryCode(nationalNumber.toString(), regionMetadata,
                                            normalizedNationalNumber, keepRawInput, phoneNumber);
    } catch (NumberParseException e) {
      Matcher matcher = PLUS_CHARS_PATTERN.matcher(nationalNumber.toString());
      if (e.getErrorType() == NumberParseException.ErrorType.INVALID_COUNTRY_CODE &&
          matcher.lookingAt()) {
        // Strip the plus-char, and try again.
        countryCode = maybeExtractCountryCode(nationalNumber.substring(matcher.end()),
                                              regionMetadata, normalizedNationalNumber,
                                              keepRawInput, phoneNumber);
        if (countryCode == 0) {
View Full Code Here

      }
    }
    if (numberFormat == PhoneNumberFormat.RFC3966) {
      // Strip any leading punctuation.
      Matcher matcher = SEPARATOR_PATTERN.matcher(formattedNationalNumber);
      if (matcher.lookingAt()) {
        formattedNationalNumber = matcher.replaceFirst("");
      }
      // Replace the rest with a dash between each number group.
      formattedNationalNumber = matcher.reset(formattedNationalNumber).replaceAll("-");
    }
View Full Code Here

  private ValidationResult testNumberLengthAgainstPattern(Pattern numberPattern, String number) {
    Matcher numberMatcher = numberPattern.matcher(number);
    if (numberMatcher.matches()) {
      return ValidationResult.IS_POSSIBLE;
    }
    if (numberMatcher.lookingAt()) {
      return ValidationResult.TOO_LONG;
    } else {
      return ValidationResult.TOO_SHORT;
    }
  }
View Full Code Here

   * Strips the IDD from the start of the number if present. Helper function used by
   * maybeStripInternationalPrefixAndNormalize.
   */
  private boolean parsePrefixAsIdd(Pattern iddPattern, StringBuilder number) {
    Matcher m = iddPattern.matcher(number);
    if (m.lookingAt()) {
      int matchEnd = m.end();
      // Only strip this if the first digit after the match is not a 0, since country calling codes
      // cannot begin with 0.
      Matcher digitMatcher = CAPTURING_DIGIT_PATTERN.matcher(number.substring(matchEnd));
      if (digitMatcher.find()) {
View Full Code Here

    if (number.length() == 0) {
      return CountryCodeSource.FROM_DEFAULT_COUNTRY;
    }
    // Check to see if the number begins with one or more plus signs.
    Matcher m = PLUS_CHARS_PATTERN.matcher(number);
    if (m.lookingAt()) {
      number.delete(0, m.end());
      // Can now normalize the rest of the number since we've consumed the "+" sign at the start.
      normalize(number);
      return CountryCodeSource.FROM_NUMBER_WITH_PLUS_SIGN;
    }
View Full Code Here

      // Early return for numbers of zero length.
      return false;
    }
    // Attempt to parse the first digits as a national prefix.
    Matcher prefixMatcher = regexCache.getPatternForRegex(possibleNationalPrefix).matcher(number);
    if (prefixMatcher.lookingAt()) {
      Pattern nationalNumberRule =
          regexCache.getPatternForRegex(metadata.getGeneralDesc().getNationalNumberPattern());
      // Check if the original number is viable.
      boolean isViableOriginalNumber = nationalNumberRule.matcher(number).matches();
      // prefixMatcher.group(numOfGroups) == null implies nothing was captured by the capturing
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.