Class KiwiRegexes


  • public class KiwiRegexes
    extends Object
    Static helper methods related to regular expression processing.
    • Constructor Detail

      • KiwiRegexes

        public KiwiRegexes()
    • Method Detail

      • extractMatchOrNull

        public static String extractMatchOrNull​(Pattern pattern,
                                                String input)
        Extracts a regex match as a String, or return null if no match found.
        Parameters:
        pattern - the Pattern
        input - the input to match against
        Returns:
        a string containing the match, or null if no match found
      • extractMatchOrThrow

        public static String extractMatchOrThrow​(Pattern pattern,
                                                 String input)
        Extracts a regex match as a String, or throws an exception if no match found.
        Parameters:
        pattern - the Pattern
        input - the input to match against
        Returns:
        a string containing the match
        Throws:
        NoMatchesFoundException - if the input does not match the pattern
      • extractMatch

        public static Optional<String> extractMatch​(Pattern pattern,
                                                    String input)
        Extracts a regex match as a String.
        Parameters:
        pattern - the Pattern
        input - the input to match against
        Returns:
        an Optional containing the match, or empty Optional if no match