sections

Returns an array of string sections between two key values.

Input Parameters:

{{ input | sections: '<beginning key>', '<ending key>', '<array size limit (optional)>', '<nth occurrence of beggining key (optional)>', '<nth occurrence of ending key (optional)>' }}

Examples:

Input

{% assign text = 'use the keys to find multiple sections of text between keys and cut out the text between two keys.' %}
{% assign sections = text | sections: 'keys', 'text' %}
{% for section in sections %}
{{section}}
{% endfor %}

Output

 to find multiple sections of 
 and cut out the 
.

To limit the size of the array to the first n sections found, pass a positive integer into the array size limit parameter.

Input

{% assign text = 'use the keys to find multiple sections of text between keys and cut out the text between two keys.' %}
{% assign sections = text | sections: 'keys', 'text', 1 %}
{% for section in sections %}
{{section}}
{% endfor %}

Output

To pickup all sections without a limit, pass -1 into the array size limit parameter.

Input

Output

If the nth occurrence of beginning key is not found, an empty value will be returned.

Input

Output

If the nth occurrence of ending key is not found, the remaining input will be returned.

Input

Output

Last updated