Substring: Difference between revisions
Content added Content deleted
(→{{header|D}}: add implementation) |
|||
Line 120: | Line 120: | ||
(let ((pos (search substring string))) |
(let ((pos (search substring string))) |
||
(subseq string pos (+ pos m)))))</lang> |
(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}}== |
=={{header|E}}== |