Jump to content

Substring: Difference between revisions

→‎{{header|D}}: add implementation
(→‎{{header|D}}: add implementation)
Line 120:
(let ((pos (search substring string)))
(subseq string pos (+ pos m)))))</lang>
 
=={{header|D}}==
<lang d>
import std.stdio;
import std.string;
void main() {
char[]ostr = "The quick brown fox jumps over the lazy dog.";
int n = 5,m = 3,o;
writefln("%s",ostr[n..n+m]);
writefln("%s",ostr[n..$]);
writefln("%s",ostr[0..$-1]);
o = ostr.find("q");
writefln("%s",ostr[o..o+m]);
o = ostr.find("qu");
writefln("%s",ostr[o..o+m]);
}
</lang>
 
=={{header|E}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.