substring - UDM Command
Syntax
substring variable_name string {pos=position | startseq=sequence [startseqnum=number]} {length=length | endseq=sequence [endseqnum=number]} [case=yes|no]
Description
The substring command finds a substring in an existing string and stores it in a variable.
The first parameter, variable_name, specifies the name of the variable into which the substring is placed. The string parameter specifies the string from which the substring is taken.
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.
Parameters
Parameter | Description |
variable_name | Name of the existing variable into which the substring is placed. |
string | String from which the substring is taken. |
pos=position | Starting position of string to be taken (one based index) |
startseq=sequence | Starting position of string to be taken (following a specific character sequence) |
startseqnum=number | Occurrence number of starting position of string to be taken (following a specific character sequence) |
length=length | Length of the string to be taken |
endseq=sequence | Ending position of string to be taken (following a specific character sequence) |
endseqnum=number | Occurrence number of ending position of string to be taken (following a specific character sequence |
case=yes | no | Specification for whether or not the comparisons of the start and end sequences are case sensitive (yes) or case insensitive (no). Default is no. |
Examples
The following examples illustrate the substring command: