Zyle Moore
02/28/2026, 3:57 AM.pattern?
val alphaNumericHyphen = Regex("[A-Za-z0-9\\-]");
val atLeastOneAlphaNumericHyphen = Regex("${alphaNumericHyphen.pattern}+")
val xAlphaNumericHyphen = Regex("[Xx]-${alphaNumericHyphen.pattern}")ephemient
02/28/2026, 6:46 AMephemient
02/28/2026, 6:51 AMconst val alphaNumHyphenPat = """[0-9A-Za-z\-]"""
val someAlphaNumHyphen = "$alphaNumHyphenPat+".toRegex()
val xAlphaNumHyphen = "[Xx]-$alphaNumHyphenPat+".toRegex()
so they'll all be constant strings after compilation and we're not trying to pretend that regex are reusableZyle Moore
02/28/2026, 6:52 AMalphaNumHyphenPat ?ephemient
02/28/2026, 6:54 AM// language=RegExp
or with IntelliJ annotations
@Language("RegExp")Zyle Moore
02/28/2026, 7:07 AMCLOVIS
03/02/2026, 9:51 AMorg.jetbrains:annotations:26.0.2-1 if you want to use the annotation on non-JVM platforms (the Kotlin stdlib depends on an old version where the annotations were JVM-only)