diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt index db19b63a2..068dfce1d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt @@ -83,4 +83,16 @@ object RegexUtils { return this.any { it.matches(string) } } + /** + * Returns a list of all occurrences of a pattern within the [input] string. + */ + fun Pattern.findAll(input: String): List<String> { + val matcher = matcher(input) + + return buildList { + while (matcher.find()) { + add(matcher.group()) + } + } + } } |