Package org.elasticsearch.common.regex
Class Regex
- java.lang.Object
-
- org.elasticsearch.common.regex.Regex
-
public class Regex extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intUNICODE_CHARACTER_CLASSThis Regex /Patternflag is supported from Java 7 on.
-
Constructor Summary
Constructors Constructor Description Regex()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Patterncompile(String regex, String flags)static intflagsFromString(String flags)static StringflagsToString(int flags)static booleanisMatchAllPattern(String str)static booleanisSimpleMatchPattern(String str)Is the str a simple match pattern.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[] patterns, String[] types)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(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.static AutomatonsimpleMatchToAutomaton(String pattern)Return anAutomatonthat matches the given pattern.static AutomatonsimpleMatchToAutomaton(String... patterns)Return an Automaton that matches the union of the provided patterns.
-
-
-
Field Detail
-
UNICODE_CHARACTER_CLASS
public static final int UNICODE_CHARACTER_CLASS
This Regex /Patternflag is supported from Java 7 on. If set on a Java6 JVM the flag will be ignored.- See Also:
- Constant Field Values
-
-
Method Detail
-
isSimpleMatchPattern
public static boolean isSimpleMatchPattern(String str)
Is the str a simple match pattern.
-
isMatchAllPattern
public static boolean isMatchAllPattern(String str)
-
simpleMatchToAutomaton
public static Automaton simpleMatchToAutomaton(String pattern)
Return anAutomatonthat matches the given pattern.
-
simpleMatchToAutomaton
public static Automaton simpleMatchToAutomaton(String... patterns)
Return an Automaton that matches the union of the provided patterns.
-
simpleMatch
public static boolean simpleMatch(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.- Parameters:
pattern- the pattern to match againststr- the String to match- Returns:
- whether the String matches the given pattern
-
simpleMatch
public static boolean simpleMatch(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.- Parameters:
patterns- the patterns to match againststr- the String to match- Returns:
- whether the String matches any of the given patterns
-
simpleMatch
public static boolean simpleMatch(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.
-
flagsFromString
public static int flagsFromString(String flags)
-
flagsToString
public static String flagsToString(int flags)
-
-