aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/util/regex.kt
blob: 97c279763292db3ec577b8d0ae373c46da742791 (plain)
1
2
3
4
5
6
7
8
9
10
/*
 * 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)