code: public static Pattern compilePattern(final String queryString) {
          final StringBuilder queryBuilder = new StringBuilder();
  
          final Matcher queryMatcher = IPersonAttributeDao.WILDCARD_PATTERN.matcher(queryString);
  
          if (!queryMatcher.find()) {
              return Pattern.compile(Pattern.quote(queryString));
          }
  
          int start = queryMatcher.start();
          int previousEnd = -1;
          if (start > 0) {
              final String queryPart = queryString.substring(0, start);
              final String quotedQueryPart = Pattern.quote(queryPart);
              queryBuilder.append(quotedQueryPart);
          }
          queryBuilder.append(".*");
  
          do {
              start = queryMatcher.start();
  
              if (previousEnd != -1) {
                  final String queryPart = queryString.substring(previousEnd, start);
                  final String quotedQueryPart = Pattern.quote(queryPart);
                  queryBuilder.append(quotedQueryPart);
                  queryBuilder.append(".*");
              }
  
              previousEnd = queryMatcher.end();
          } while (queryMatcher.find());
  
          if (previousEnd < queryString.length()) {
              final String queryPart = queryString.substring(previousEnd);
              final String quotedQueryPart = Pattern.quote(queryPart);
              queryBuilder.append(quotedQueryPart);
          }
  
          return Pattern.compile(queryBuilder.toString());
      }
docs: Converts a String using the {@link IPersonAttributeDao#WILDCARD} into a valid regular expression
  {@link Pattern} with the {@link IPersonAttributeDao#WILDCARD} replaced by .* and the rest of the
  string escaped using {@link Pattern#quote(String)}
  
  @param queryString query String
  @return compiled Pattern