September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
12
Task/String-matching/Kotlin/string-matching.kotlin
Normal file
12
Task/String-matching/Kotlin/string-matching.kotlin
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// version 1.0.6
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val s1 = "abracadabra"
|
||||
val s2 = "abra"
|
||||
println("$s1 begins with $s2 : ${s1.startsWith(s2)}")
|
||||
println("$s1 ends with $s2 : ${s1.endsWith(s2)}")
|
||||
val b = s2 in s1
|
||||
print("$s1 contains $s2 : $b")
|
||||
if (b) println(" at locations ${s1.indexOf(s2) + 1} and ${s1.lastIndexOf(s2) + 1}")
|
||||
else println()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue