RosettaCodeData/Task/Substring/Yorick/substring.yorick
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

16 lines
543 B
Text

str = "abcdefgh";
n = 2;
m = 3;
// starting from n character in and of m length
write, strpart(str, n:n+m-1);
// starting from n character in, up to the end of the string
write, strpart(str, n:);
// whole string minus last character
write, strpart(str, :-1);
// starting from a known character within the string and of m length
match = strfind("d", str);
write, strpart(str, [match(1), match(1)+m]);
// starting from a known substring within the string and of m length
match = strfind("cd", str);
write, strpart(str, [match(1), match(1)+m]);