11 lines
533 B
Text
11 lines
533 B
Text
|
|
V s = ‘abcdefgh’
|
|||
|
|
V n = 2
|
|||
|
|
V m = 3
|
|||
|
|
V char = ‘d’
|
|||
|
|
V chars = ‘cd’
|
|||
|
|
print(s[n - 1 .+ m]) // starting from n=2 characters in and m=3 in length
|
|||
|
|
print(s[n - 1 ..]) // starting from n characters in, up to the end of the string
|
|||
|
|
print(s[0 .< (len)-1]) // whole string minus last character
|
|||
|
|
print(s[s.index(char) .+ m]) // starting from a known character char="d" within the string and of m length
|
|||
|
|
print(s[s.index(chars) .+ m]) // starting from a known substring chars="cd" within the string and of m length
|