HomeManualTopicsTypesSymbols

std_types::string/std::between

returns the substring between two expressions

Parameters

str
the input string
expr_1
the expression on the left hand side
expr_2
the expression on the right hand side
nth (default: 1)
look for the nth occurrence of *expr_1* instead for the first one

Results

None

Description

If the specified expressions are found within the string the substring between the expressions is returned. Otherwise the empty string is returned.

If nth is specified then the nth occurence of the first expression expr_1 is looked for. If there are not at least n matches for expr_1 within str then the empty string is returned.

Example

$path "/home/user/" $user_name between(path "/" "/" 2) println! user_name

Output

user

Topic

Strings

Implements

std::between returns the substring between the two specified expressions

See also

std_types::string/std::before returns the substring before the specified expression
std_types::string/std::behind returns the substring after the specified expression
std_types::string/std::until returns the substring until (including) the specified expression
std_types::string/std::from returns the substring starting with the specified expression