Interface Pattern

All Known Implementing Classes:
Pattern

public interface Pattern
  • Field Details

  • Method Details

    • pattern

      String pattern()
      See Also:
    • matcher

      Matcher matcher(CharSequence subject)
      See Also:
    • flags

      int flags()
      See Also:
    • matches

      boolean matches(CharSequence subject)
      Equivalent with pattern.matcher(subject).matches(), but is slightly faster because it does not expose the Matcher object and can thus save some overhead.
      Returns:
      Whether the subject matches this pattern
    • matches

      boolean matches(CharSequence subject, int regionStart)
      Equivalent with pattern.matcher(subject ).region(regionStart, subject .length()).matches(), but is slightly faster because it does not expose the Matcher object and can thus save some overhead.
      Returns:
      Whether the substring of the subject, starting at regionStart, matches this pattern
    • matches

      boolean matches(CharSequence subject, int regionStart, int regionEnd)
      Equivalent with pattern.matcher(subject ).region(regionStart, regionEnd ).matches(), but is slightly faster because it does not expose the Matcher object and can thus save some overhead.
      Returns:
      Whether the substring of the subject, designated by regionStart and regionEnd, matches this pattern
    • split

      String[] split(CharSequence input)
      See Also:
    • split

      String[] split(CharSequence input, int limit)
      See Also:
    • asPredicate

      Predicate<String> asPredicate()
      Creates a predicate that tests if this pattern is found in a given input string.

      API Note: This method creates a predicate that behaves as if it creates a matcher from the input sequence and then calls find, for example a predicate of the form:

           s -> matcher(s).find();
       
      Returns:
      The predicate which can be used for finding a match on a subsequence of a string
      Since:
      JRE 1.8
    • asMatchPredicate

      Predicate<String> asMatchPredicate()
      Creates a predicate that tests if this pattern matches a given input string.

      API Note: This method creates a predicate that behaves as if it creates a matcher from the input sequence and then calls matches, for example a predicate of the form:

           s -> matcher(s).matches();
       
      Returns:
      The predicate which can be used for matching an input string against this pattern.
      Since:
      JRE 11
    • splitAsStream

      Stream<String> splitAsStream(CharSequence input)
      Creates a stream from the given input sequence around matches of this pattern. The stream returned by this method contains each substring of the input sequence that is terminated by another subsequence that matches this pattern or is terminated by the end of the input sequence. The substrings in the stream are in the order in which they occur in the input. Trailing empty strings will be discarded and not encountered in the stream.

      If this pattern does not match any subsequence of the input then the resulting stream has just one element, namely the input sequence in string form.

      When there is a positive-width match at the beginning of the input sequence then an empty leading substring is included at the beginning of the stream. A zero-width match at the beginning however never produces such empty leading substring.

      If the input sequence is mutable, it must remain constant during the execution of the terminal stream operation. Otherwise, the result of the terminal stream operation is undefined.

      Parameters:
      input - The character sequence to be split
      Returns:
      The stream of strings computed by splitting the input around matches of this pattern
      Since:
      JRE 1.8