In Kotlin, regular expressions are represented by the Regex class from the kotlin.text package. Instances of this class are immutable, and we can create a new one by using one of the following constructors:
public actual constructor(pattern: String) : this(Pattern.compile(pattern))
public actual constructor(pattern: String, option: RegexOption) : this(Pattern.compile(pattern, ensureUnicodeCase(option.value)))
public actual constructor(pattern: String, options: Set<RegexOption>) : this(Pattern.compile(pattern, ensureUnicodeCase(options.toInt())))
RegexOption is an enum that we can use to specify any additional options. This defines the following objects:
- IGNORE_CASE: You can use this if you need to ignore a string
- MULTILINE: This is a line terminator or the end of the input sequence, and it must be used just after or just before ^ and $ subexpressions...