Substring: Difference between revisions
Content added Content deleted
(Undo revision 109590 by Markhobley The change asks for a lot of tasks to be updated without flagging such, or mentioning it on the talk page.) |
(Updated D code) |
||
Line 411: | Line 411: | ||
{{works with|D|2}} |
{{works with|D|2}} |
||
<lang d>import std.stdio, std.string; |
<lang d>import std.stdio, std.string; |
||
void main() { |
void main() { |
||
const s = "the quick brown fox jumps over the lazy dog"; |
|||
enum n = 5, m = 3; |
|||
writeln(s[n .. n + m]); |
|||
writeln(s[n .. $]); |
|||
writeln(s[0 .. $ - 1]); |
|||
i = |
const i = s.indexOf("q"); |
||
writeln(s[i .. i + m]); |
|||
const j = s.indexOf("qu"); |
|||
writeln(s[j .. j + m]); |
|||
}</lang> |
}</lang> |
||
Output: |
Output: |