Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Panel
Table of Contents

Anchor
1154069
1154069
Syntax

deletestringvariable_name pos=position |{startseq=sequence [startseqnum=number]} length=length |{endseq=sequence [endseqnum=number]} [case=yes|no]

Anchor
1154073
1154073
Description

Anchor
1154074
1154074
The deletestring command removes a substring from an existing string.

Anchor
1154075
1154075
The first parameter, VARIABLE_NAME, is the name of an existing variable.

Anchor
1154076
1154076
The beginning of the sequence to be deleted is indicated by either its starting position (one-based index, using the pos parameter) or as immediately following a particular occurrence of a character sequence (startseq specifies the sequence and the optional startseqnum specifies the occurrence number).

Anchor
1154077
1154077
The end of the substring is determined by either specifying the length of the substring using the length parameter or giving a sequence that indicates the end of the substring (endseq specifies the ending sequence and the optional endseqnum specifies the occurrence number).


<ac:structured-macro ac:name="anchor" ac:schema-version="1" ac:macro-id="33cd4a58-e72a-43bd-b885-47ae6da84d85"><ac:parameter ac:name="">1154078</ac:parameter></ac:structured-macro> The optional case parameter specifies whether the comparisons of the sequences are case-sensitive (yes) or case-insensitive (no). [Default is no.]

Anchor
1154079
1154079
The _lastrc.message built-in variable will contain:

  • NO_MATCH if start or end sequences were specified and could not be matched
  • INVALID_VALUE if the starting position or length are out of range
  • SUCCESS if a sub-string was successfully deleted

Anchor
1154083
1154083

Anchor
1154084
1154084
Parameters

Parameter

Description

variable_name

Name of an existing variable.

pos=position

Starting position of sequence to be deleted (one based index).

startseq=sequence

Starting position of sequence to be deleted (following a specific character sequence).

startseqnum=number

Occurrence number of starting position of sequence to be deleted (following a specific character sequence).

length=length

Length of the substring to be deleted.

endseq=sequence

Ending position of sequence to be deleted (preceding a specific character sequence).

endseqnum=number

Occurrence number of ending position of sequence to be deleted (preceding a specific character sequence).

case=yes | no

Indicates whether or not the comparisons of the sequence are case-insensitive.

Default is no.

Anchor
1154127
1154127
Examples

Anchor
1154128
1154128
The following examples illustrate how deletestring is used starting with a sample string called mystring with an initial value of This is not just some sample text:

Anchor
1154129
1154129

Panel
set mystring="This is not just some sample text"
deletestring mystring pos=8 length=4*=
echo "$(mystring)"
This is just some sample text

set mystring="This is not just some sample text"
deletestring mystring startseq=" " startseqnum=2 endseq=" "
echo "$(mystring)"
This is just some sample text

set mystring="This is not just some sample text"
deletestring mystring startseq=" " startseqnum=2 length=21
echo "$(mystring)"
This is text

Anchor
1124154
1124154