Class StringPatterns

java.lang.Object
eu.bandm.tools.paisley.StringPatterns

@Generated(generator="eu.bandm.tools.expander", version="", timestamp="2026-01-12T17:56:35") public abstract class StringPatterns extends Object
Static factory methods for creating patterns for strings and regular expressions.
See Also:
  • Method Details

    • startsWith

      public static Pattern<String> startsWith(String prefix)
      Returns a pattern that matches strings starting with a given prefix.

      A pattern returned by this method is deterministic and binds no variables.

      Parameters:
      prefix - the prefix to match against
      Returns:
      a pattern that matches the string target if and only if it starts with prefix
      Throws:
      NullPointerException - if prefix is null.
      See Also:
    • endsWith

      public static Pattern<String> endsWith(String suffix)
      Returns a pattern that matches strings ending with a given suffix.

      A pattern returned by this method is deterministic and binds no variables.

      Parameters:
      suffix - the suffix to match against
      Returns:
      a pattern that matches the string target if and only if it ends with suffix
      Throws:
      NullPointerException - if suffix is null.
      See Also:
    • equalsIgnoreCase

      public static Pattern<String> equalsIgnoreCase(String str)
      Returns a pattern that matches strings that equal a given string ignoring case.

      A pattern returned by this method is deterministic and binds no variables.

      Parameters:
      str - the str to match against
      Returns:
      a pattern that matches the string target if and only if it equals str ignoring case
      Throws:
      NullPointerException - if str is null.
      See Also:
    • matches

      public static Pattern<String> matches(String regex)
      Returns a pattern that matches strings that match a given regex string.

      A pattern returned by this method is deterministic and binds no variables.

      Parameters:
      regex - the regex string to match against
      Returns:
      a pattern that matches the string target if and only if it matches regex
      Throws:
      NullPointerException - if regex is null.
      See Also:
    • length

      public static Pattern<String> length(Pattern<? super Integer> length)
      Returns a pattern that matches strings whose length is matched by a given pattern.

      A pattern returned by this method is deterministic and binds no variables.

      Parameters:
      length - the pattern to match string length against
      Returns:
      a pattern that matches the string target if and only if its length is matched by length
      Throws:
      NullPointerException - if length is null.
      See Also:
    • matches

      public static Pattern<String> matches(String regex, Pattern<? super String>... ps)
      Returns a pattern that matches strings that match a given regex string, with given patterns matching the substrings captured by groups.

      Note that explicit groups are numbered from one; the implicit group with number zero is the whole pattern.

      Parameters:
      regex - the regex string to match against
      ps - an array of patterns to match against the substrings captured by groups.
      Returns:
      a pattern that matches the string target if and only if it matches regex
      Throws:
      NullPointerException - if regex is null, or if ps is or contains null.
      IllegalArgumentException - if the number of group patterns does not match the number of capturing groups
      See Also:
    • find

      @SafeVarargs public static Pattern<String> find(String regex, Pattern<? super String>... groups)
    • tokenize

      public static Pattern<String> tokenize(Pattern<? super String> body)
      Returns a pattern that matches a string by matching a given subpattern disjunctively against its tokenized substrings.

      This method uses the Java whitespace characters " \t\n\r\f" as delimiters.

      Parameters:
      body - the pattern to match agains tokenized substrings
      Returns:
      a pattern that matches a string by matching body disjunctively against its tokenized substrings
      Throws:
      NullPointerException - if body is null
      See Also:
    • tokenize

      public static Pattern<String> tokenize(String delim, Pattern<? super String> body)
      Returns a pattern that matches a string by matching a given subpattern disjunctively against its tokenized substrings.
      Parameters:
      delim - the delimiters
      body - the pattern to match agains tokenized substrings
      Returns:
      a pattern that matches a string by matching body disjunctively against its tokenized substrings
      Throws:
      NullPointerException - if body is null
      See Also:
    • tokenize

      public static Pattern<String> tokenize(String delim, boolean returnDelims, Pattern<? super String> body)
      Returns a pattern that matches a string by matching a given subpattern disjunctively against its tokenized substrings.
      Parameters:
      delim - the delimiters
      returnDelims - flag indicating whether to return the delimiters as tokens
      body - the pattern to match agains tokenized substrings
      Returns:
      a pattern that matches a string by matching body disjunctively against its tokenized substrings
      Throws:
      NullPointerException - if body is null
      See Also: