From b19acb3645deb1554a54a9bd5588c985e50f4040 Mon Sep 17 00:00:00 2001 From: Andrey Polyakov Date: Wed, 2 Aug 2023 17:39:43 +0200 Subject: [PATCH] update: rename raw strings to multiline --- docs/topics/jvm/java-to-kotlin-idioms-strings.md | 4 ++-- docs/topics/strings.md | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/topics/jvm/java-to-kotlin-idioms-strings.md b/docs/topics/jvm/java-to-kotlin-idioms-strings.md index e00a792e007..9a1f36aebad 100644 --- a/docs/topics/jvm/java-to-kotlin-idioms-strings.md +++ b/docs/topics/jvm/java-to-kotlin-idioms-strings.md @@ -199,14 +199,14 @@ System.out.println("Anonymized input: '" + replacementResult + "'"); In Kotlin, you use the [Regex](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/) class that simplifies working with regular expressions. -Additionally, use [raw strings](strings.md#string-literals) to simplify a regex pattern +Additionally, use [multiline strings](strings.md#multiline-strings) to simplify a regex pattern by reducing the count of backslashes: ```kotlin fun main() { //sampleStart // Kotlin - val regex = Regex("""\w*\d+\w*""") // raw string + val regex = Regex("""\w*\d+\w*""") // multiline string val input = "login: Pokemon5, password: 1q2w3e4r5t" val replacementResult = regex.replace(input, replacement = "xxx") println("Initial input: '$input'") diff --git a/docs/topics/strings.md b/docs/topics/strings.md index cb662cf4361..311c2efc44d 100644 --- a/docs/topics/strings.md +++ b/docs/topics/strings.md @@ -49,7 +49,7 @@ println(s + "def") ``` {kotlin-runnable="true" kotlin-min-compiler-version="1.3"} -> In most cases using [string templates](#string-templates) or [raw strings](#raw-strings) is preferable to string concatenation. +> In most cases using [string templates](#string-templates) or [multiline strings](#multiline-strings) is preferable to string concatenation. > {type="note"} @@ -58,7 +58,7 @@ println(s + "def") Kotlin has two types of string literals: * [Escaped strings](#escaped-strings) -* [Raw strings](#raw-strings) +* [Multiline strings](#multiline-strings) ### Escaped strings @@ -72,9 +72,9 @@ val s = "Hello, world!\n" Escaping is done in the conventional way, with a backslash (`\`). See [Characters](characters.md) page for the list of supported escape sequences. -### Raw strings +### Multiline strings -_Raw strings_ can contain newlines and arbitrary text. It is delimited by a triple quote (`"""`), contains no escaping and can contain newlines and any other characters: +_Multiline strings_ can contain newlines and arbitrary text. It is delimited by a triple quote (`"""`), contains no escaping and can contain newlines and any other characters: ```kotlin val text = """ @@ -83,7 +83,7 @@ val text = """ """ ``` -To remove leading whitespace from raw strings, use the [`trimMargin()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/trim-margin.html) function: +To remove leading whitespace from multiline strings, use the [`trimMargin()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/trim-margin.html) function: ```kotlin val text = """ @@ -123,8 +123,8 @@ fun main() { ``` {kotlin-runnable="true" kotlin-min-compiler-version="1.3"} -You can use templates both in raw and escaped strings. -To insert the dollar sign `$` in a raw string (which doesn't support backslash escaping) before any symbol, +You can use templates both in multiline and escaped strings. +To insert the dollar sign `$` in a multiline string (which doesn't support backslash escaping) before any symbol, which is allowed as a beginning of an [identifier](https://kotlinlang.org/docs/reference/grammar.html#identifiers), use the following syntax: