On Thursday, 5 December 2019 at 11:28:51 UTC, Marcone wrote:
Simple example:writeln("Hi\nHow are you?\nGood".splitLines()[0][0..?lastIndexOf(r"\")]);How to refer to this string in lastIndexOf() without create a variable?Thank you.
One solution:
writeln(
"Hello\nHow are you?\nGood"
.splitLines()
.map!(x => x[0..x.lastIndexOf("o")])
);
But be careful: lastIndexOf could be < 0 if string is not found.
