RosettaCodeData/Task/Substring/11l/substring.11l

11 lines
533 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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