Package org.kiwiproject.util.regex
Class KiwiRegexes
java.lang.Object
org.kiwiproject.util.regex.KiwiRegexes
Static helper methods related to regular expression processing.
-
Method Summary
Modifier and TypeMethodDescriptionextractMatch(Pattern pattern, String input) Extracts a regex match as a String.static Stream<MatchResult>extractMatches(Pattern pattern, String input) static StringextractMatchOrNull(Pattern pattern, String input) Extracts a regex match as a String, or returnnullif no match found.static StringextractMatchOrThrow(Pattern pattern, String input) Extracts a regex match as a String, or throws an exception if no match found.
-
Method Details
-
extractMatchOrNull
Extracts a regex match as a String, or returnnullif no match found.- Parameters:
pattern- thePatterninput- the input to match against- Returns:
- a string containing the match, or
nullif no match found
-
extractMatchOrThrow
Extracts a regex match as a String, or throws an exception if no match found.- Parameters:
pattern- thePatterninput- the input to match against- Returns:
- a string containing the match
- Throws:
NoMatchesFoundException- if the input does not match the pattern
-
extractMatch
Extracts a regex match as a String.- Parameters:
pattern- thePatterninput- the input to match against- Returns:
- an Optional containing the match, or empty Optional if no match
-
extractMatches
- Parameters:
pattern- thePatterninput- the input to match against- Returns:
- a stream of
MatchResult
-