From bf8df0f764b1a38b4a2523d9feef5cefd87774aa Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 22 Sep 2015 20:52:56 +0300 Subject: [PATCH] Move toRegex extension in kotlin package --- libraries/stdlib/src/kotlin/text/regex/RegexExtensions.kt | 8 ++++++++ libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt | 2 ++ 2 files changed, 10 insertions(+) diff --git a/libraries/stdlib/src/kotlin/text/regex/RegexExtensions.kt b/libraries/stdlib/src/kotlin/text/regex/RegexExtensions.kt index 344543b96b0..247fafae66c 100644 --- a/libraries/stdlib/src/kotlin/text/regex/RegexExtensions.kt +++ b/libraries/stdlib/src/kotlin/text/regex/RegexExtensions.kt @@ -16,3 +16,11 @@ public fun String.toRegex(option: RegexOption): Regex = Regex(this, option) * Converts the string into a regular expression [Regex] with the specified set of [options]. */ public fun String.toRegex(options: Set): Regex = Regex(this, options) + +/** + * Converts this [Pattern] to an instance of [Regex]. + * + * Provides the way to use Regex API on the instances of [Pattern]. + */ +@JvmVersion +public fun java.util.regex.Pattern.toRegex(): Regex = Regex(this) \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt b/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt index eeb592db58b..3d47d8cf3c9 100644 --- a/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt +++ b/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt @@ -211,6 +211,8 @@ public class Regex internal constructor(private val nativePattern: Pattern) { * * Provides the way to use Regex API on the instances of [Pattern]. */ +@Deprecated("Use extension toRegex instead in kotlin package.") +@HiddenDeclaration public fun Pattern.toRegex(): Regex = Regex(this)