Use kotlin.text.Regex instead of java.util.regex.Pattern

Proprietary

Replaces JVM-only java.util.regex.Pattern calls with their multiplatform Kotlin equivalents: s.toRegex() and Regex.escape(s).

org.openrewrite.kotlin.migrate.UseKotlinRegex$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.migrate.UseKotlinRegex$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Use String.toRegex() instead of Pattern.compile(s)
  2. Use Regex.escape(s) instead of Pattern.quote(s)