Regex

expect class Regex(pattern: String, options: Set<RegexOption>)
actual class Regex(pattern: String, options: Set<RegexOption>) : Serializable

Represents a compiled regular expression. Provides functions to match strings in text with a pattern, replace the found occurrences and split text around matches.

For pattern syntax reference see Pattern.

actual class Regex(pattern: String, options: Set<RegexOption>)

Represents a compiled regular expression. Provides functions to match strings in text with a pattern, replace the found occurrences and split text around matches.

For pattern syntax reference see MDN RegExp and http://www.w3schools.com/jsref/jsref_obj_regexp.asp.

actual class Regex(pattern: String, options: Set<RegexOption>)

Represents a compiled regular expression. Provides functions to match strings in text with a pattern, replace the found occurrences and split text around matches.

Constructors

Regex
Link copied to clipboard
expect fun Regex(pattern: String)
actual fun Regex(pattern: String)

Creates a regular expression from the specified pattern string and the default options.

actual fun Regex(pattern: String)

Creates a regular expression from the specified pattern string and the default options.

actual fun Regex(pattern: String)

Creates a regular expression from the specified pattern string and the default options.

Regex
Link copied to clipboard
expect fun Regex(pattern: String, option: RegexOption)
actual fun Regex(pattern: String, option: RegexOption)

Creates a regular expression from the specified pattern string and the specified single option.

actual fun Regex(pattern: String, option: RegexOption)

Creates a regular expression from the specified pattern string and the specified single option.

actual fun Regex(pattern: String, option: RegexOption)

Creates a regular expression from the specified pattern string and the specified single option.

Regex
Link copied to clipboard
expect fun Regex(pattern: String, options: Set<RegexOption>)
actual fun Regex(pattern: String, options: Set<RegexOption>)

Creates a regular expression from the specified pattern string and the specified set of options.

actual fun Regex(pattern: String, options: Set<RegexOption>)

Creates a regular expression from the specified pattern string and the specified set of options.

actual fun Regex(pattern: String, options: Set<RegexOption>)

Creates a regular expression from the specified pattern string and the specified set of options.

Types

Companion
Link copied to clipboard
expect object Companion
actual object Companion
actual object Companion
actual object Companion

Functions

containsMatchIn
Link copied to clipboard
expect fun containsMatchIn(input: CharSequence): Boolean
actual fun containsMatchIn(input: CharSequence): Boolean

Indicates whether the regular expression can find at least one match in the specified input.

actual fun containsMatchIn(input: CharSequence): Boolean

Indicates whether the regular expression can find at least one match in the specified input.

actual fun containsMatchIn(input: CharSequence): Boolean

Indicates whether the regular expression can find at least one match in the specified input.

find
Link copied to clipboard
expect fun find(input: CharSequence, startIndex: Int = 0): MatchResult?

Returns the first match of a regular expression in the input, beginning at the specified startIndex.

actual fun find(input: CharSequence, startIndex: Int = 0): MatchResult?

Returns the first match of a regular expression in the input, beginning at the specified startIndex.

actual fun find(input: CharSequence, startIndex: Int = 0): MatchResult?

Returns the first match of a regular expression in the input, beginning at the specified startIndex.

actual fun find(input: CharSequence, startIndex: Int = 0): MatchResult?

Returns the first match of a regular expression in the input, beginning at the specified startIndex.

findAll
Link copied to clipboard
expect fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult>

Returns a sequence of all occurrences of a regular expression within the input string, beginning at the specified startIndex.

actual fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult>

Returns a sequence of all occurrences of a regular expression within the input string, beginning at the specified startIndex.

actual fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult>

Returns a sequence of all occurrences of a regular expression within the input string, beginning at the specified startIndex.

actual fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult>

Returns a sequence of all occurrences of a regular expression within the input string, beginning at the specified startIndex.

matchEntire
Link copied to clipboard
expect fun matchEntire(input: CharSequence): MatchResult?
actual fun matchEntire(input: CharSequence): MatchResult?

Attempts to match the entire input CharSequence against the pattern.

actual fun matchEntire(input: CharSequence): MatchResult?

Attempts to match the entire input CharSequence against the pattern.

actual fun matchEntire(input: CharSequence): MatchResult?

Attempts to match the entire input CharSequence against the pattern.

matches
Link copied to clipboard
expect infix fun matches(input: CharSequence): Boolean
actual infix fun matches(input: CharSequence): Boolean

Indicates whether the regular expression matches the entire input.

actual infix fun matches(input: CharSequence): Boolean

Indicates whether the regular expression matches the entire input.

actual infix fun matches(input: CharSequence): Boolean

Indicates whether the regular expression matches the entire input.

replace
Link copied to clipboard
expect fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String
expect fun replace(input: CharSequence, replacement: String): String
actual fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String

Replaces all occurrences of this regular expression in the specified input string with the result of the given function transform that takes MatchResult and returns a string to be used as a replacement for that match.

actual fun replace(input: CharSequence, replacement: String): String

Replaces all occurrences of this regular expression in the specified input string with specified replacement expression.

actual inline fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String

Replaces all occurrences of this regular expression in the specified input string with the result of the given function transform that takes MatchResult and returns a string to be used as a replacement for that match.

actual fun replace(input: CharSequence, replacement: String): String

Replaces all occurrences of this regular expression in the specified input string with specified replacement expression.

actual fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String

Replaces all occurrences of this regular expression in the specified input string with the result of the given function transform that takes MatchResult and returns a string to be used as a replacement for that match.

actual fun replace(input: CharSequence, replacement: String): String

Replaces all occurrences of this regular expression in the specified input string with specified replacement expression.

replaceFirst
Link copied to clipboard
expect fun replaceFirst(input: CharSequence, replacement: String): String
actual fun replaceFirst(input: CharSequence, replacement: String): String

Replaces the first occurrence of this regular expression in the specified input string with specified replacement expression.

actual fun replaceFirst(input: CharSequence, replacement: String): String

Replaces the first occurrence of this regular expression in the specified input string with specified replacement expression.

actual fun replaceFirst(input: CharSequence, replacement: String): String

Replaces the first occurrence of this regular expression in the specified input string with specified replacement expression.

split
Link copied to clipboard
expect fun split(input: CharSequence, limit: Int = 0): List<String>

Splits the input CharSequence around matches of this regular expression.

actual fun split(input: CharSequence, limit: Int = 0): List<String>

Splits the input CharSequence around matches of this regular expression.

actual fun split(input: CharSequence, limit: Int = 0): List<String>

Splits the input CharSequence around matches of this regular expression.

actual fun split(input: CharSequence, limit: Int = 0): List<String>

Splits the input CharSequence around matches of this regular expression.

toPattern
Link copied to clipboard
fun toPattern(): Pattern

Returns an instance of Pattern with the same pattern string and options as this instance of Regex has.

toString
Link copied to clipboard
open override fun toString(): String

Returns the string representation of this regular expression, namely the pattern of this regular expression.

open override fun toString(): String

Returns the string representation of this regular expression, namely the pattern of this regular expression.

open override fun toString(): String

Returns the string representation of this regular expression, namely the pattern of this regular expression.

Properties

options
Link copied to clipboard
expect val options: Set<RegexOption>
actual val options: Set<RegexOption>

The set of options that were used to create this regular expression.

actual val options: Set<RegexOption>

The set of options that were used to create this regular expression.

actual val options: Set<RegexOption>

The set of options that were used to create this regular expression.

pattern
Link copied to clipboard
expect val pattern: String
actual val pattern: String

The pattern string of this regular expression.

actual val pattern: String

The pattern string of this regular expression.

actual val pattern: String

The pattern string of this regular expression.