exprv4:reference:methods:string_slice_methods




String Slice Methods

String slice methods return parts of a string.

Indexes are zero-based.


substr(start)

Returns text from `start` to the end of the string.

Argument Type Description
`start` number Zero-based start index.

Returns: string.

Example:

'abcdef'.substr(2);        // 'cdef'

substr(start, count)

Returns `count` characters starting at `start`.

Argument Type Description
`start` number Zero-based start index.
`count` number Number of characters to return.

Returns: string.

Example:

'abcdef'.substr(2, 3);     // 'cde'

slice(start)

Alias for `substr(start)`.

Argument Type Description
`start` number Zero-based start index.

Returns: string.

Example:

'abcdef'.slice(2);         // 'cdef'

slice(start, count)

Alias for `substr(start, count)`.

Argument Type Description
`start` number Zero-based start index.
`count` number Number of characters to return.

Returns: string.

Example:

'abcdef'.slice(2, 3);      // 'cde'

subspan(start)

Returns text from `start` to the end of the string.

Argument Type Description
`start` number Zero-based start index.

Returns: string.

Example:

'abcdef'.subspan(2);       // 'cdef'

subspan(start, end)

Returns text from `start` up to `end`.

Argument Type Description
`start` number Zero-based start index.
`end` number End index.

Returns: string.

Example:

'abcdef'.subspan(2, 5);    // 'cde'

span(start)

Alias for `subspan(start)`.

Argument Type Description
`start` number Zero-based start index.

Returns: string.

Example:

'abcdef'.span(2);          // 'cdef'

span(start, end)

Alias for `subspan(start, end)`.

Argument Type Description
`start` number Zero-based start index.
`end` number End index.

Returns: string.

Example:

'abcdef'.span(2, 5);       // 'cde'

before(text)

Returns the part of the string before the first matching separator text.

Argument Type Description
`text` any Separator text.

Returns: string.

Example:

'key=value'.before('=');   // 'key'

after(text)

Returns the part of the string after the first matching separator text.

Argument Type Description
`text` any Separator text.

Returns: string.

Example:

'key=value'.after('=');    // 'value'

Previous: String Basic Methods

Next: String Parsing Methods

exprv4/reference/methods/string_slice_methods.txt · Last modified: by 127.0.0.1

Page Tools