Package org.kiwiproject.util.regex
Class KiwiRegexes
- java.lang.Object
-
- org.kiwiproject.util.regex.KiwiRegexes
-
public class KiwiRegexes extends Object
Static helper methods related to regular expression processing.
-
-
Constructor Summary
Constructors Constructor Description KiwiRegexes()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<String>extractMatch(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 Detail
-
extractMatchOrNull
public static String extractMatchOrNull(Pattern pattern, String input)
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
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- thePatterninput- 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- thePatterninput- the input to match against- Returns:
- an Optional containing the match, or empty Optional if no match
-
extractMatches
public static Stream<MatchResult> extractMatches(Pattern pattern, String input)
- Parameters:
pattern- thePatterninput- the input to match against- Returns:
- a stream of
MatchResult
-
-