Package org.rapidcontext.util
Class RegexUtil
java.lang.Object
org.rapidcontext.util.RegexUtil
A set of utility methods for handling regular expressions.
- Version:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
firstMatch
(Pattern[] arr, String str) Returns the first match from an array of regular expressions.static String
firstMatch
(Pattern re, String str) Returns the first match for a regular expression.static String
Converts a glob expression to a regular expression.
-
Method Details
-
firstMatch
Returns the first match for a regular expression.- Parameters:
re
- the compiled regex patternstr
- the string to match- Returns:
- the matched substring, or null if no match was found
-
firstMatch
Returns the first match from an array of regular expressions.- Parameters:
arr
- the array of compiled regex patternsstr
- the string to match- Returns:
- the matched substring, or null if no match was found
-
fromGlob
Converts a glob expression to a regular expression. Handles the special characters '?', '*' and '**'.- Parameters:
glob
- the glob to convert- Returns:
- the corresponding regular expression
-