core :: Text :: substring_from
self
beginning at the from
positionassert "abcd".substring_from(1) == "bcd"
assert "abcd".substring_from(-1) == "abcd"
assert "abcd".substring_from(2) == "cd"
As with substring, a from
index < 0 will be replaced by 0
# Create a substring from `self` beginning at the `from` position
#
# ~~~
# assert "abcd".substring_from(1) == "bcd"
# assert "abcd".substring_from(-1) == "abcd"
# assert "abcd".substring_from(2) == "cd"
# ~~~
#
# As with substring, a `from` index < 0 will be replaced by 0
fun substring_from(from: Int): SELFTYPE
do
if from >= self.length then return empty
if from < 0 then from = 0
return substring(from, length - from)
end
lib/core/text/abstract_text.nit:175,2--189,4
redef fun substring_from(from) do
if from >= self._length then return empty
if from <= 0 then return self
var c = char_to_byte_index(from)
var st = c - _first_byte
var fln = byte_length - st
return new FlatString.full(items, fln, c, _length - from)
end
lib/core/text/flat.nit:673,2--680,4