Files
Firmament/src/main/kotlin/moe/nea/firmament/util/regex.kt
2023-08-01 00:06:19 +02:00

11 lines
266 B
Kotlin

/*
* SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package moe.nea.firmament.util
inline fun <T> String.ifMatches(regex: Regex, block: (MatchResult) -> T): T? =
regex.matchEntire(this)?.let(block)