Java コードからパッケージtoRegex()
の拡張機能を使用しようとしています。kotlin.text
そのファイルのコードは次のとおりです。
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("StringsKt")
package kotlin.text
/**
* Converts the string into a regular expression [Regex] with the default options.
*/
@kotlin.internal.InlineOnly
public inline fun String.toRegex(): Regex = Regex(this)
/**
* Converts the string into a regular expression [Regex] with the specified single [option].
*/
@kotlin.internal.InlineOnly
public inline fun String.toRegex(option: RegexOption): Regex = Regex(this, option)
/**
* Converts the string into a regular expression [Regex] with the specified set of [options].
*/
@kotlin.internal.InlineOnly
public inline fun String.toRegex(options: Set<RegexOption>): Regex = Regex(this, options)
残念ながら、Java コードから関数を呼び出すことに成功しませんでした。私は何かが欠けていると思います。これが私の試みです:
import kotlin.text.StringsKt;
...
StringsKt.toRegex("some_string"); // Doesn't compile.
コンパイルしません。