20 lines
461 B
Kotlin
20 lines
461 B
Kotlin
package nl.voidcorp.yeetbot
|
|
|
|
import com.google.gson.GsonBuilder
|
|
import java.util.regex.Pattern
|
|
import java.util.regex.PatternSyntaxException
|
|
|
|
val gson = GsonBuilder().setPrettyPrinting().create()
|
|
|
|
fun Any.toJson():String = gson.toJson(this)
|
|
|
|
fun checkRegex(pattern: String): Boolean {
|
|
var exc: PatternSyntaxException? = null
|
|
try {
|
|
Pattern.compile(pattern)
|
|
} catch (e: PatternSyntaxException) {
|
|
exc = e
|
|
}
|
|
|
|
return exc == null
|
|
} |