Syntax
substring variable_name string {pos=position | startseq=sequence [startseqnum=number]} {length=length | endseq=sequence [endseqnum=number]} [case=yes|no]
Description
...
The beginning of the
substring is marked either by a position or a start sequence and optional sequence occurrence number (similar to
deletestring). The end of the substring is determined by specifying the length of the substring or an ending sequence and optional sequence occurrence number, also similar to
deletestring.
The case parameter specifies whether comparisons for start and end sequences are case sensitive (yes) or case insensitive (no). [Default is no.]
_lastrc.message is set to NO_MATCH if a start or end sequence was specified and could not be found. If the position or length are specified and contain invalid values,
_lastrc.message will contain INVALID_VALUE.
...
The following examples illustrate the
substring command:
Panel |
---|
Html bobswift |
---|
<pre>
substring res "This is fun" pos=6 length=2
echo "$(res)"
is
substring res "This is less fun" startseq=" " endseq=" "
echo "$(res)"
is
substring res "This This is fun fun" startseq=" " endseq=" " +
endseqnum=3
echo "$(res)"
This is fun
</pre>
|
|