We’re going to discuss another new string featuring Kotlin called raw strings or triple-quoted strings, you’ll hear them refer to using both terms. Now, when you use triple-quoted strings, you don’t have to escape characters, they can also contain line breaks, but you can’t use special characters like tab and newline characters. So let’s look at an example…
If we wanted to type a string which contains a file path like this
[code]val filePath = “c:\dir1\dir2″[/code]
We will get an error because the compiler thinks we are trying to escape the d.
So we will have to do this
[code]val filePath = “c:\\dir1\\dir2″[/code]
But in kotlin now we can just use 3 quotations instead of \\
[code]val filePath = “””c:\dir1\dir2″””[/code]
another thing we can do is to use new line inside a string
like if you wrote
val dirList = """dir1
dir2
dir3
dir4"""

the output will be

dir1
dir2
dir3
dir4

so we didn’t use /n even though it worked:D yeees kotlin

what we can do also, is instead of using new line, we can use (trim margin). With trim margin what you do is you pass it a character or you can use the default margin character and then the character that you pass it, append to the beginning of every line.
like this,
val test = """I am line one *I am line two *I am line Three """.trimMargin("*")

the output will be

I am line one
I am line two
I am line three
Which gave the same effect, a new line when * is found, But in the first way if we wanted to align our code with spaces or tabs, it will print those white spaces, not only align the code with them, so using trim margin will ignore the white spaces and focus only on the given character.
it’s default characters (|) so if you made it like this
val test = """I am line one |I am line two |I am line Three """.trimMargin()
You will get the same result without the need to pass any character.
Now, of course, you can also use string templates within triple-quoted strings, like this (notice the extra new lines which trimMargin will ignore)
val language1 = "Kotlin"
val language2 = "Java"

val text = """I am trying to learn $language1 


|but I am still into $language2""".trimMargin()

the output will be

I am trying to learn Kotlin
but I am still into Java

That’s it for raw strings!:)  Now pardon me I have a parrot to train 😀