Skip to main content

String

Git Source

Functions

truncate32

Truncates a string to 32 bytes

function truncate32(string memory str_) internal pure returns (string memory);

substring

Returns a substring of a string

function substring(string memory str_, uint256 startIndex_, uint256 endIndex_)
internal
pure
returns (string memory);

Parameters

NameTypeDescription
str_stringThe string to get the substring of
startIndex_uint256The index to start the substring at
endIndex_uint256The index to end the substring at

Returns

NameTypeDescription
<none>stringresultString The substring

substringFrom

Returns a substring of a string from a given index

function substringFrom(string memory str_, uint256 startIndex_) internal pure returns (string memory);

Parameters

NameTypeDescription
str_stringThe string to get the substring of
startIndex_uint256The index to start the substring at

Returns

NameTypeDescription
<none>stringresultString The substring

Errors

EndBeforeStartIndex

error EndBeforeStartIndex(uint256 startIndex, uint256 endIndex);

EndIndexOutOfBounds

error EndIndexOutOfBounds(uint256 endIndex, uint256 length);