Class Regex

java.lang.Object
org.elasticsearch.common.regex.Regex

public class Regex
extends java.lang.Object
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int UNICODE_CHARACTER_CLASS
    This Regex / Pattern flag is supported from Java 7 on.
  • Constructor Summary

    Constructors
    Constructor Description
    Regex()  
  • Method Summary

    Modifier and Type Method Description
    static java.util.regex.Pattern compile​(java.lang.String regex, java.lang.String flags)  
    static int flagsFromString​(java.lang.String flags)  
    static java.lang.String flagsToString​(int flags)  
    static boolean isMatchAllPattern​(java.lang.String str)  
    static boolean isSimpleMatchPattern​(java.lang.String str)
    Is the str a simple match pattern.
    static boolean simpleMatch​(java.lang.String[] patterns, java.lang.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 boolean simpleMatch​(java.lang.String[] patterns, java.lang.String[] types)  
    static boolean simpleMatch​(java.lang.String pattern, java.lang.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 boolean simpleMatch​(java.lang.String pattern, java.lang.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 boolean simpleMatch​(java.util.List<java.lang.String> patterns, java.lang.String str)
    Similar to simpleMatch(String[], String), but accepts a list of strings instead of an array of strings for the patterns to match.
    static org.apache.lucene.util.automaton.Automaton simpleMatchToAutomaton​(java.lang.String pattern)
    Return an Automaton that matches the given pattern.
    static org.apache.lucene.util.automaton.Automaton simpleMatchToAutomaton​(java.lang.String... patterns)
    Return an Automaton that matches the union of the provided patterns.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNICODE_CHARACTER_CLASS

      public static final int UNICODE_CHARACTER_CLASS
      This Regex / Pattern flag is supported from Java 7 on. If set on a Java6 JVM the flag will be ignored.
      See Also:
      Constant Field Values
  • Constructor Details

    • Regex

      public Regex()
  • Method Details

    • isSimpleMatchPattern

      public static boolean isSimpleMatchPattern​(java.lang.String str)
      Is the str a simple match pattern.
    • isMatchAllPattern

      public static boolean isMatchAllPattern​(java.lang.String str)
    • simpleMatchToAutomaton

      public static org.apache.lucene.util.automaton.Automaton simpleMatchToAutomaton​(java.lang.String pattern)
      Return an Automaton that matches the given pattern.
    • simpleMatchToAutomaton

      public static org.apache.lucene.util.automaton.Automaton simpleMatchToAutomaton​(java.lang.String... patterns)
      Return an Automaton that matches the union of the provided patterns.
    • simpleMatch

      public static boolean simpleMatch​(java.lang.String pattern, java.lang.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. Matching is case sensitive.
      Parameters:
      pattern - the pattern to match against
      str - the String to match
      Returns:
      whether the String matches the given pattern
    • simpleMatch

      public static boolean simpleMatch​(java.lang.String pattern, java.lang.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.
      Parameters:
      pattern - the pattern to match against
      str - the String to match
      caseInsensitive - true if ASCII case differences should be ignored
      Returns:
      whether the String matches the given pattern
    • simpleMatch

      public static boolean simpleMatch​(java.lang.String[] patterns, java.lang.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 against
      str - the String to match
      Returns:
      whether the String matches any of the given patterns
    • simpleMatch

      public static boolean simpleMatch​(java.util.List<java.lang.String> patterns, java.lang.String str)
      Similar to simpleMatch(String[], String), but accepts a list of strings instead of an array of strings for the patterns to match.
    • simpleMatch

      public static boolean simpleMatch​(java.lang.String[] patterns, java.lang.String[] types)
    • compile

      public static java.util.regex.Pattern compile​(java.lang.String regex, java.lang.String flags)
    • flagsFromString

      public static int flagsFromString​(java.lang.String flags)
    • flagsToString

      public static java.lang.String flagsToString​(int flags)