Class RegularExpression

java.lang.Object
org.apache.jena.ext.xerces.impl.xpath.regex.RegularExpression
All Implemented Interfaces:
Serializable

public class RegularExpression extends Object implements Serializable
A regular expression matching engine using Non-deterministic Finite Automaton (NFA). This engine does not conform to the POSIX regular expression.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new RegularExpression instance.
    RegularExpression(String regex, String options)
    Creates a new RegularExpression instance with options.
    RegularExpression(String regex, String options, Locale locale)
    Creates a new RegularExpression instance with options.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Return true if patterns are the same and the options are equivalent.
    int
    Return the number of regular expression groups.
    Returns a option string.
     
    int
     
    boolean
    matches(char[] target)
    Checks whether the target text contains this pattern or not.
    boolean
    matches(char[] target, int start, int end)
    Checks whether the target text contains this pattern in specified range or not.
    boolean
    matches(char[] target, int start, int end, Match match)
    Checks whether the target text contains this pattern in specified range or not.
    boolean
    matches(char[] target, Match match)
    Checks whether the target text contains this pattern or not.
    boolean
    matches(String target)
    Checks whether the target text contains this pattern or not.
    boolean
    matches(String target, int start, int end)
    Checks whether the target text contains this pattern in specified range or not.
    boolean
    matches(String target, int start, int end, Match match)
    Checks whether the target text contains this pattern in specified range or not.
    boolean
    matches(String target, Match match)
    Checks whether the target text contains this pattern or not.
    boolean
    Checks whether the target text contains this pattern or not.
    boolean
    Checks whether the target text contains this pattern or not.
    void
    setPattern(String newPattern)
     
    void
    setPattern(String newPattern, String options)
     
    void
    setPattern(String newPattern, String options, Locale locale)
     
    void
    setPattern(String newPattern, Locale locale)
     
    Represents this instence in String.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RegularExpression

      public RegularExpression(String regex) throws ParseException
      Creates a new RegularExpression instance.
      Parameters:
      regex - A regular expression
      Throws:
      ParseException - regex is not conforming to the syntax.
    • RegularExpression

      public RegularExpression(String regex, String options) throws ParseException
      Creates a new RegularExpression instance with options.
      Parameters:
      regex - A regular expression
      options - A String consisted of "i" "m" "s" "u" "w" "," "X"
      Throws:
      ParseException - regex is not conforming to the syntax.
    • RegularExpression

      public RegularExpression(String regex, String options, Locale locale) throws ParseException
      Creates a new RegularExpression instance with options.
      Parameters:
      regex - A regular expression
      options - A String consisted of "i" "m" "s" "u" "w" "," "X"
      Throws:
      ParseException - regex is not conforming to the syntax.
  • Method Details

    • matches

      public boolean matches(char[] target)
      Checks whether the target text contains this pattern or not.
      Returns:
      true if the target is matched to this regular expression.
    • matches

      public boolean matches(char[] target, int start, int end)
      Checks whether the target text contains this pattern in specified range or not.
      Parameters:
      start - Start offset of the range.
      end - End offset +1 of the range.
      Returns:
      true if the target is matched to this regular expression.
    • matches

      public boolean matches(char[] target, Match match)
      Checks whether the target text contains this pattern or not.
      Parameters:
      match - A Match instance for storing matching result.
      Returns:
      Offset of the start position in target; or -1 if not match.
    • matches

      public boolean matches(char[] target, int start, int end, Match match)
      Checks whether the target text contains this pattern in specified range or not.
      Parameters:
      start - Start offset of the range.
      end - End offset +1 of the range.
      match - A Match instance for storing matching result.
      Returns:
      Offset of the start position in target; or -1 if not match.
    • matches

      public boolean matches(String target)
      Checks whether the target text contains this pattern or not.
      Returns:
      true if the target is matched to this regular expression.
    • matches

      public boolean matches(String target, int start, int end)
      Checks whether the target text contains this pattern in specified range or not.
      Parameters:
      start - Start offset of the range.
      end - End offset +1 of the range.
      Returns:
      true if the target is matched to this regular expression.
    • matches

      public boolean matches(String target, Match match)
      Checks whether the target text contains this pattern or not.
      Parameters:
      match - A Match instance for storing matching result.
      Returns:
      Offset of the start position in target; or -1 if not match.
    • matches

      public boolean matches(String target, int start, int end, Match match)
      Checks whether the target text contains this pattern in specified range or not.
      Parameters:
      start - Start offset of the range.
      end - End offset +1 of the range.
      match - A Match instance for storing matching result.
      Returns:
      Offset of the start position in target; or -1 if not match.
    • matches

      public boolean matches(CharacterIterator target)
      Checks whether the target text contains this pattern or not.
      Returns:
      true if the target is matched to this regular expression.
    • matches

      public boolean matches(CharacterIterator target, Match match)
      Checks whether the target text contains this pattern or not.
      Parameters:
      match - A Match instance for storing matching result.
      Returns:
      Offset of the start position in target; or -1 if not match.
    • setPattern

      public void setPattern(String newPattern) throws ParseException
      Throws:
      ParseException
    • setPattern

      public void setPattern(String newPattern, Locale locale) throws ParseException
      Throws:
      ParseException
    • setPattern

      public void setPattern(String newPattern, String options) throws ParseException
      Throws:
      ParseException
    • setPattern

      public void setPattern(String newPattern, String options, Locale locale) throws ParseException
      Throws:
      ParseException
    • getPattern

      public String getPattern()
    • toString

      public String toString()
      Represents this instence in String.
      Overrides:
      toString in class Object
    • getOptions

      public String getOptions()
      Returns a option string. The order of letters in it may be different from a string specified in a constructor or setPattern().
      See Also:
    • equals

      public boolean equals(Object obj)
      Return true if patterns are the same and the options are equivalent.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getNumberOfGroups

      public int getNumberOfGroups()
      Return the number of regular expression groups. This method returns 1 when the regular expression has no capturing-parenthesis.