Class RegularExpression

java.lang.Object
org.apache.jena.ext.xerces_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 Details

    • RegularExpression

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

      public RegularExpression(String regex, String options) throws RegexParseException
      Creates a new RegularExpression instance with options.
      Parameters:
      regex - A regular expression
      options - A String consisted of "i" "m" "s" "u" "w" "," "X"
      Throws:
      RegexParseException - 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, org.apache.jena.ext.xerces_regex.RegexMatch 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, org.apache.jena.ext.xerces_regex.RegexMatch 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, org.apache.jena.ext.xerces_regex.RegexMatch 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, org.apache.jena.ext.xerces_regex.RegexMatch 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, org.apache.jena.ext.xerces_regex.RegexMatch 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)
    • setPattern

      public void setPattern(String newPattern, String options)
    • 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.