lines
Returns a string which is the subset of all lines of haystack
specified in line_numbers
. Any lines specified in line_numbers
that are not present in `haystack`
are ignored.
Usage
{{lines haystack line_numbers flags="t"}}
Arguments
haystack
The input string
line_numbers
A list of line numbers or ranges of numbers, separated by commas. For example, to specify 1, 3, 5, as well as all lines 10 through 20, 1,3,5,10-20
.
flags
- t: trim the final result prior to returning (remove all whitespace from beginning and end)
Examples
Return a range of lines
{{lines email.body '1-3' flags='t'}}
Line 1.
Line 2.
Line 3.
Return a single line
{{lines email.body '2' flags='t'}}
Line 2.
Return nothing when a non-existent line is requested
{{lines email.body '20' flags='t'}}
Return a complex range selection
{{lines email.body '1,3-4' flags='t'}}
Line 1.
Line 3.
Line 4.
Return lines in a new order
{{lines email.body '4,3,2,1' flags='t'}}
Line 4.
Line 3.
Line 2.
Line 1.