java.lang.Object
org.elasticsearch.common.regex.Regex
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThis Regex /Patternflag is supported from Java 7 on. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Patternstatic intflagsFromString(String flags) static StringflagsToString(int flags) static booleanisMatchAllPattern(String str) static booleanIs the str a simple match pattern.static booleanReturns true if the str ends with "*".static booleanisSuffixWildcard(String str) Returns true if the str ends with ".*".static booleansimpleMatch(String[] patterns, String str) Match a String against the given patterns, supporting the following simple pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an arbitrary number of pattern parts), as well as direct equality.static booleansimpleMatch(String pattern, String str) Match a String against the given pattern, supporting the following simple pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an arbitrary number of pattern parts), as well as direct equality.static booleansimpleMatch(String pattern, String str, boolean caseInsensitive) Match a String against the given pattern, supporting the following simple pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an arbitrary number of pattern parts), as well as direct equality.static booleansimpleMatch(List<String> patterns, String str) Similar tosimpleMatch(String[], String), but accepts a list of strings instead of an array of strings for the patterns to match.simpleMatcher(String... patterns) Create aPredicatethat matches the given patterns.static org.apache.lucene.util.automaton.AutomatonsimpleMatchToAutomaton(String pattern) Return a deterministicAutomatonthat matches the given pattern.static org.apache.lucene.util.automaton.AutomatonsimpleMatchToAutomaton(String... patterns) Return a deterministic Automaton that matches the union of the provided patterns.static org.apache.lucene.util.automaton.AutomatonReturn a non-determinizedAutomatonthat matches the given pattern.static org.apache.lucene.util.automaton.AutomatonsimpleMatchToNonDeterminizedAutomaton(String... patterns) Returns a non-deterministicAutomatonthat matches the union of the given patterns.
-
Field Details
-
UNICODE_CHARACTER_CLASS
public static final int UNICODE_CHARACTER_CLASSThis Regex /Patternflag is supported from Java 7 on. If set on a Java6 JVM the flag will be ignored.- See Also:
-
-
Constructor Details
-
Regex
public Regex()
-
-
Method Details
-
isSimpleMatchPattern
Is the str a simple match pattern. -
isMatchAllPattern
-
isSuffixMatchPattern
Returns true if the str ends with "*". -
isSuffixWildcard
Returns true if the str ends with ".*". -
simpleMatchToNonDeterminizedAutomaton
public static org.apache.lucene.util.automaton.Automaton simpleMatchToNonDeterminizedAutomaton(String pattern) Return a non-determinizedAutomatonthat matches the given pattern. WARNING: Use this method only when the resultingAutomatonis used in contexts that do not require determinism (e.g., checking the intersection of automatons). For pattern matching withCharacterRunAutomaton, a deterministic automaton is required. In that case, usesimpleMatchToAutomaton(java.lang.String)instead. -
simpleMatchToAutomaton
Return a deterministicAutomatonthat matches the given pattern. -
simpleMatchToNonDeterminizedAutomaton
public static org.apache.lucene.util.automaton.Automaton simpleMatchToNonDeterminizedAutomaton(String... patterns) Returns a non-deterministicAutomatonthat matches the union of the given patterns. WARNING: Use this method only when the resultingAutomatonis used in contexts that do not require determinism (e.g., checking the intersection of automatons). For pattern matching withCharacterRunAutomaton, a deterministic automaton is required. In that case, usesimpleMatchToAutomaton(java.lang.String)instead. -
simpleMatchToAutomaton
Return a deterministic Automaton that matches the union of the provided patterns. -
simpleMatcher
Create aPredicatethat matches the given patterns. Evaluating the returned predicate against aStringyields the same result as runningsimpleMatch(String[], String)but may run faster, especially in the case when there are multiple patterns. -
simpleMatch
Match a String against the given pattern, supporting the following simple pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an arbitrary number of pattern parts), as well as direct equality. Matching is case sensitive.- Parameters:
pattern- the pattern to match againststr- the String to match- Returns:
- whether the String matches the given pattern
-
simpleMatch
Match a String against the given pattern, supporting the following simple pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an arbitrary number of pattern parts), as well as direct equality.- Parameters:
pattern- the pattern to match againststr- the String to matchcaseInsensitive- true if ASCII case differences should be ignored- Returns:
- whether the String matches the given pattern
-
simpleMatch
Match a String against the given patterns, supporting the following simple pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an arbitrary number of pattern parts), as well as direct equality.- Parameters:
patterns- the patterns to match againststr- the String to match- Returns:
- whether the String matches any of the given patterns
-
simpleMatch
Similar tosimpleMatch(String[], String), but accepts a list of strings instead of an array of strings for the patterns to match. -
compile
-
flagsFromString
-
flagsToString
-