Package java.util.regex

Examples of java.util.regex.Pattern$Category


        // and mark the result as not valid
        if(name.indexOf(textFilters[j]) == -1) {
         
            // double check against reg-expr if exists
         
          Pattern p = textFilterPatterns[j];
         
          if ( p == null  || !p.matcher( name ).find()){
         
            valid = false;
         
            break;
          }
        }
      }
     
      //if invalid after name check, let's get to the next result
      if(!valid) {
        continue;
      }
     
      for(int j = 0 ; j < excludeTextFilters.length ; j++) {
       
        //If one of the text filters do not match, let's not keep testing the others
        // and mark the result as not valid
        if(name.indexOf(excludeTextFilters[j]) != -1) {
          valid = false;
          break;
        }else{
          Pattern p = excludeTextFilterPatterns[j];
         
          if ( p != null  && p.matcher( name ).find()){
            valid = false;
            break;
          }
        }
      }
View Full Code Here


          TableCellImpl.TEXT_COMPARATOR);
      if (index < 0) {

        int iEarliest = -1;
        String s = filter.regex ? filter.text : "\\Q" + filter.text + "\\E";
        Pattern pattern = Pattern.compile(s, Pattern.CASE_INSENSITIVE);
        for (int i = 0; i < cells.length; i++) {
          Matcher m = pattern.matcher(cells[i].getText());
          if (m.find() && (m.start() < iEarliest || iEarliest == -1)) {
            iEarliest = m.start();
            index = i;
          }
        }
View Full Code Here

        String uniqueRandomFileName = MessageFormat.format(pattern, new Object[] { date, date });
        return new File(directory, uniqueRandomFileName);
    }

    public static String unescapeEntities(String str) {
        Pattern hexEntityPattern = Pattern.compile("&([a-fA-F0-9]+);");
        Pattern decimalEntityPattern = Pattern.compile("&#([0-9]+);");
        str = replaceNumericEntities(str, hexEntityPattern, 16);
        return replaceNumericEntities(str, decimalEntityPattern, 10);
    }
View Full Code Here

        //if you change anything, we'll destroy our combined search pattern. This will recreate it with the
        //latest settings when its next asked for.
        combinedSearchPattern = null;

        String searchExpression = fileLinkDefinition.getSearchExpression();
        Pattern pattern = Pattern.compile( searchExpression, getSearchPatternFlags() );
        destinationMap.put( pattern, fileLinkDefinition);
    }
View Full Code Here

   private static FileLinkDefinition getMatchingFileLinkDefinition( String text, Map<Pattern,FileLinkDefinition> map )
   {
      Iterator<Pattern> iterator = map.keySet().iterator();
      while( iterator.hasNext() )
      {
         Pattern pattern = iterator.next();
         Matcher matcher = pattern.matcher( text );
         if( matcher.find( 0 ) )
         {
            return map.get( pattern );
         }
      }
View Full Code Here

    */
   public List<FileLink> parseText( String text )
   {
      List<FileLink> fileLinks = new ArrayList<FileLink>();

      Pattern combinedSearchPattern = fileLinkDefinitionLord.getSearchPattern();
      Matcher matcher = combinedSearchPattern.matcher( text );

      int index = 0;

      boolean foundAMatch = matcher.find( index );
      while( foundAMatch )
View Full Code Here

        if (pattern.length() == 0) {
            return null;
        }

        Pattern camelCasePattern = getPatternForName(pattern);
        Pattern normalisedCamelCasePattern = Pattern.compile(camelCasePattern.pattern(), Pattern.CASE_INSENSITIVE);
        String normalisedPattern = pattern.toUpperCase();

        Set<String> matches1 = new TreeSet<String>();
        Set<String> matches2 = new TreeSet<String>();

        for (String candidate : items) {
            if (camelCasePattern.matcher(candidate).matches()) {
                matches1.add(candidate);
                continue;
            }
            if (normalisedCamelCasePattern.matcher(candidate).lookingAt()) {
                matches2.add(candidate);
                continue;
            }
            if (StringUtils.getLevenshteinDistance(normalisedPattern, candidate.toUpperCase()) <= Math.min(3,
                    pattern.length() / 2)) {
View Full Code Here

        return null;
    }

    private static Pattern getPatternForName(String name) {
        Pattern boundaryPattern = Pattern.compile("((^|\\p{Punct})\\p{javaLowerCase}+)|(\\p{javaUpperCase}\\p{javaLowerCase}*)");
        Matcher matcher = boundaryPattern.matcher(name);
        int pos = 0;
        StringBuilder builder = new StringBuilder();
        while (matcher.find()) {
            String prefix = name.substring(pos, matcher.start());
            if (prefix.length() > 0) {
View Full Code Here

    if (sourceRef != null) {
      ContentNetworkUtils.setSourceRef(tabID, sourceRef, false);

      if (MultipleDocumentInterface.SIDEBAR_SECTION_PLUS.equals(tabID) ||
          MultipleDocumentInterface.SIDEBAR_SECTION_BURN_INFO.equals(tabID)) {
        Pattern pattern = Pattern.compile("http.*//[^/]+/([^.]+)");
        Matcher matcher = pattern.matcher(sourceRef);
       
        String sourceRef2;
        if (matcher.find()) {
          sourceRef2 = matcher.group(1);
        } else {
View Full Code Here

        Set<ValidationError> errors = new HashSet<ValidationError>();
        if (stringConstraint != null) {
            if (stringConstraint.required() & (object == null)) errors.add(new ValidationError(field.getName(), errorCodes[0], stringConstraint, object));
            if ((object != null) & (stringConstraint.regexp().length() > 0)) {
                try {
                    Pattern pattern = Pattern.compile(stringConstraint.regexp());
                    Matcher matcher = pattern.matcher(object.toString());
                    if (!matcher.matches()) errors.add(new ValidationError(field.getName(), errorCodes[1], stringConstraint, object));
                } catch (Exception ex) {
                    throw new ValidationException(ex);
                }
            }
View Full Code Here

TOP

Related Classes of java.util.regex.Pattern$Category

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.