Skip to main content

StringSlicer

Git Source

Functions​

slice​

Abbreviates a string.

This function uses Array Slices (https://blog.soliditylang.org/2020/05/26/array-slices/), which only work on calldata. The function must therefore live in a separate contract for a Token Resolver to use Array Slices.

function slice(string calldata _str, uint256 _start, uint256 _end) external pure returns (string memory);

Parameters

NameTypeDescription
_strstringThe string to mutate.
_startuint256The first index of the input string to include in the output.
_enduint256The last index of the input string to include in the output.

Returns

NameTypeDescription
<none>stringstring The abbreviated string.