nextind

nextind(str, i)

Get the next valid string index after i. Returns a value greater than endof(str) at or after the end of the string.

Examples

julia> str = "Julia";
julia> nextind(str, 1)
2

julia> nextind(str, 3)
4

julia> nextind(str, 5)
6

In these examples, the nextind() function is used to get the next valid index in the given string str after the specified index i. It returns the value greater than endof(str) at or after the end of the string.

Common mistake example:

julia> str = "Julia";
julia> nextind(str, 6)
ERROR: BoundsError: attempt to access 5-element String at index [6]

Here, the provided index is already at the end of the string, and attempting to access the next index leads to an error. To avoid this, ensure that the index is within the valid range of the string when using nextind().

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: