从语句编译: ExqlPattern 对象。

@param pattern - 待编译的语句

@return ExqlPattern 对象
18289
public static ExqlPattern compile(String pattern) {

        // 从缓存中获取编译好的语句
        ExqlPattern compiledPattern = cache.get(pattern);
        if (compiledPattern == null) {

            // 输出日志
            if (logger.isDebugEnabled()) {
                logger.debug("EXQL pattern compiling:\n    pattern: " + pattern);
            }

            // 重新编译语句
            ExqlCompiler compiler = new ExqlCompiler(pattern);
            compiledPattern = compiler.compile();

            // 语句的缓存
            cache.putIfAbsent(pattern, compiledPattern);
        }

        return compiledPattern;
    }
807058
public static RegexpMatcher getMatcher( String pattern, boolean multiline ) {
      if( isJDK13() ){
         return new Perl5RegexpMatcher( pattern, true );
      }else{
         return new JdkRegexpMatcher( pattern, true );
      }
   }
624482
private function matchPattern($pattern) {
        $regex = $this->patternToRegex($pattern);
        $result = preg_match($regex, $this->pathInfo);
        if ($result === false) {
            throw new Exception("拦截器匹配发生错误，错误的pathinfo模式：{$pattern}");
        }

        return $result == 1;
    }
310907
protected List<Object> filterAttributeValuesByPattern(final Set<Object> attributeValues, final Pattern pattern) {
        return attributeValues.stream().filter(v -> RegexUtils.matches(pattern, v.toString(), completeMatch)).collect(Collectors.toList());
    }
1281320
public static final String prefix(String pattern)
    {
        int idx = CharSequences.lastIndexOf(pattern, BeanHelper::separator);
        if (idx != -1)
        {
            return pattern.substring(0, idx);
        }
        else
        {
            return "";
        }
    }
444655
protected PExp patternToExp(PPattern pattern) throws AnalysisException
	{
		PatternToExpVisitor visitor = new PatternToExpVisitor(getUniqueGenerator(), af);
		return pattern.apply(visitor);
	}
514524
protected PExp patternToExp(PPattern pattern, IPogAssistantFactory af,
			UniqueNameGenerator unq)
	{
		PatternToExpVisitor visitor = new PatternToExpVisitor(unq, af);
		try
		{
			return pattern.apply(visitor);
		} catch (AnalysisException e)
		{
			return null;
		}
	}
1324545
public static String formatDate(@NotNull String pattern, @NotNull Date date) {
		return FastDateFormat.getInstance(pattern).format(date);
	}
1261214
public Set<String> keys(String pattern) {
        Set<String> result = new TreeSet<String>();
        for (String key : keys()) {
            if (key.matches(pattern)) result.add(key);
        }
        return result;
    }
373479
private static DateTimeFormatter getSafeDateTimeFormatter(final String pattern) {
		DateTimeFormatter safeFormatter = getDateTimeFormatter(pattern);

		if (Locale.UK.equals(safeFormatter.getLocale())) {
			return safeFormatter.withLocale(Locale.ENGLISH);
		}

		return safeFormatter;
	}
1157857
private Format getFormatter(final String pattern, final Object argument) {
		if (pattern.indexOf('|') != -1) {
			int start = pattern.indexOf('{');
			if (start >= 0 && start < pattern.lastIndexOf('}')) {
				return new ChoiceFormat(format(pattern, new Object[] { argument }));
			} else {
				return new ChoiceFormat(pattern);
			}
		} else {
			return new DecimalFormat(pattern, symbols);
		}
	}
1275545
@Deprecated
    public String getFields(String pattern) {
        fp.set(pattern);
        StringBuilder newPattern = new StringBuilder();
        for (Object item : fp.getItems()) {
            if (item instanceof String) {
                newPattern.append(fp.quoteLiteral((String)item));
            } else {
                newPattern.append("{" + getName(item.toString()) + "}");
            }
        }
        return newPattern.toString();
    }
187184
public static String preProcessPattern(String pattern) {
		int index = pattern.indexOf('\\');
		if (index < 0) {
			return pattern;
		}

		StringBuilder sb = new StringBuilder();
		for (int pos = 0; pos < pattern.length();) {
			char ch = pattern.charAt(pos);
			if (ch != '\\') {
				sb.append(ch);
				pos++;
				continue;
			}
			if (pos + 1 >= pattern.length()) {
				// we'll end the pattern with a '\\' char
				sb.append(ch);
				break;
			}
			ch = pattern.charAt(++pos);
			switch (ch) {
				case 'b':
					sb.append('\b');
					pos++;
					break;
				case 'f':
					sb.append('\f');
					pos++;
					break;
				case 'n':
					sb.append('\n');
					pos++;
					break;
				case '0':
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7': {
					// 1-3 octal characters: \1 \01 or \017
					pos += radixCharsToChar(sb, pattern, pos, 3, 8);
					break;
				}
				case 'r':
					sb.append('\r');
					pos++;
					break;
				case 't':
					sb.append('\t');
					pos++;
					break;
				case 'x': {
					// 1-2 hex characters: \xD or \xD9
					int adjust = radixCharsToChar(sb, pattern, pos + 1, 2, 16);
					if (adjust > 0) {
						// adjust by 1 for the x
						pos += 1 + adjust;
					} else {
						sb.append(ch);
						pos++;
					}
					break;
				}
				case ' ':
				case '\\':
				default:
					sb.append(ch);
					pos++;
					break;
			}
		}
		return sb.toString();
	}
529203
public static String format(final ZonedDateTime self, String pattern) {
        return self.format(DateTimeFormatter.ofPattern(pattern));
    }
693385
public static PatternMatcher compile(String pattern) {
    String p = pattern;
    boolean ignoreCase = false;
    if (p.startsWith("(?i)")) {
      ignoreCase = true;
      p = pattern.substring(4);
    }
    if (p.length() > 0) {
      p = "^.*(" + p + ").*$";
    }
    Parser parser = new Parser(PatternUtils.expandEscapedChars(p));
    Matcher m = Optimizer.optimize(parser.parse());
    return ignoreCase ? m.ignoreCase() : m;
  }
1209947
static List<String> parsePattern(String pattern) {
    List<String> parameters = new ArrayList<>(4);
    Matcher matcher = PARAM_REGEX.matcher(pattern);
    while (matcher.find()) {
      parameters.add(matcher.group(1));
    }
    return parameters;
  }
545883
public synchronized String format(final String pattern, final Object... args) {
		Map<String, Object> model = Collections.emptyMap();
		ModelAdaptor modelAdaptor = new ModelAdaptor() {

			@Override
			public Object getValue(TemplateContext context, Token token, List<String> segments, String expression) {
				int index = Integer.parseInt(expression) - 1;
				return args[index];
			}

            @Override
            public Iterable<Object> getIterable(Object value) {
                return null;
            }

            @Override
            public String getSpecialIteratorVariable() {
                return null;
            }

        };

		String output = transformInternal(pattern, null, model, modelAdaptor, null);
		return output;
	}