On Saturday, 26 October 2013 at 22:17:33 UTC, Ali Çehreli wrote:
Use slices:

string msg = "Hello";
string sub = msg[0 .. 2];

Yes but that works only if the string is known to contain only ASCII codes. (Otherwise, a string is a collection of UTF-8 code units.)

But that isn't how substring works. At least it seams neither Java or C# take UTF-8 encoding into account (as expected).

Though D generally has much better functions for some situations, find/until/countUntil/startsWith.

Reply via email to