substr is non-standard, and slice handles negative indexes sensibly.