val pattern: String : It contains the string describing the pattern.ĬontainsMatchIn() – This function returns a boolean indicating whether there exists any match of our pattern in the input.
val options: Set : It contains the set of options which are to be used at the time of regex creation.
(pattern: String, options: Set): This constructor creates a regular expression on the basis of the specified string pattern and the set of options specified in the set.
There are also tasks that can be done with regular expressions, but the expressions turn out to be very complicated. The option is a constant of RegexOption enum class. The regular expression language is relatively small and restricted, so not all possible string processing tasks can be done using regular expressions.
(pattern: String, option: RegexOption): This constructor creates a regular expression based on the specified pattern and the option.
(pattern: String): This constructor creates a regular expression based on the pattern string.
We can easily find use of regular expressions in different kind of software, from simplest to incredibly complex applications.īefore preceding this article have a look at Regular Expression in Java If dog doesnt match, Perl will then try the next alternative, cat. At each character position, Perl will first try to match the first alternative, dog. As before, Perl will try to match the regex at the earliest possible point in the string. An object of this class represents a regular expression, that can be used for string matching purposes. To match dog or cat, we form the regex dogcat. In Kotlin, the support for regular expression is provided through Regex class. Regular Expressions are a fundamental part of almost every programming language and Kotlin is no exception to it.