BasicString.opSlice

Returns a slice [begin .. end]. If the requested substring extends past the end of the string, the returned slice is [begin .. length()].

The slice returned may be invalidated by further calls to other member functions that modify the object.

  1. inout(CharType)[] opSlice(size_t begin, size_t end)
    struct BasicString
    inout return pure nothrow @system @nogc
    static if(allowHeap)
    inout(CharType)[]
    opSlice
    (
    const size_t begin
    ,
    const size_t end
    )
  2. inout(CharType)[] opSlice(size_t begin, size_t end)

Examples

()@system{
    BasicString!char str = "123456";
    assert(str[1 .. $-1] == "2345");
}();
()@safe{
    FixedString!(char, 20) str = "123456";
    assert(str[1 .. $-1] == "2345");
}();

Meta