Is there any documentation that clearly explains t...
# getting-started
r
Is there any documentation that clearly explains the difference between Kotlin's
Regex
vs. Java's
Pattern
?
v
You mean regarding the regex syntax?
c
Kotlin's
Regex
class is essentially a multiplatform wrapper around each platform's standard Regex implementation. As such, the specific pattern format may be slightly different between different targets, but on JVM,
Regex
delegates to
java.util.regex.Pattern
. So the only difference between
Regex
and
Pattern
is the actual Kotlin API, not the pattern syntax itself https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/
e
as the link says, Kotlin Regex syntax is Java Pattern on JVM, JS RegExp on JS, and I'm not sure what on native (it's not documented)
d
Native was implemented from scratch to match JVM iirc.
e
I see harmony_regex tests in the kotlin.git/kotlin-native so that checks out
would be nice if the documentation said anything about it though… my default assumption for native languages is PCRE unless otherwise specified
☝️ 2
c
yeah, PCRE would have been my guess too
Doesn't count as docs I guess
😂 1
r
Thanks @Casey Brooks: I was aware that Regex (on JVM) used the Java Pattern syntax, but it wasn't clear from the text that Regex = Pattern.
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.