String Functions
This section contains the intrinsic functions that are used for working together with string values.
.instr()
Prototype
.instr
(
, <sourcetext>
) <searchtext>
Return types
.nul, .inf, integer
Description
Returns the one-based position of the first occurrence of one string within another. If the substring is not found then zero is returned.
Parameters
sourcetext
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf , unless the second parameter is
.nul |
string
| The string to find the substring in |
searchtext
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf , unless the first parameter is
.nul |
string
| The substring to search for. If this is the empty string then the return
value will be 0, unless the first parameter is .nul or
.inf
|
.len()
Prototype
.len
(
) <sourcetext>
Return types
.nul, .inf, integer
Description
Determines the length of a string.
Parameters
sourcetext
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf |
string
| The string to return the length of |
.like1()
Description
Compares a string with a pattern and returns .true
if the string
matches the pattern, or .false
otherwise.
Prototype
.like1
( string
, string
)
Parameters
Parameter | Default value | Type name | Description |
---|---|---|---|
None |
string
| The string to test against the pattern. | |
None |
string
| The pattern to test the string against. The string is matched against the pattern on a character by character basis, with the exception of the * wildcard described below. The string is considered to match the pattern is every character in it is matched by the characters in the pattern, and neither has any characters in excess. Matching can be performed either in a case sensitive mode, or a case insensitive mode. With the exception of the special pattern characters described below, a character in the string matches a character in the pattern if either the characters are the same, or if case insensitive testing is being done and the characters are the same when converted to lower case. The special pattern characters are:
|
.lstr()
Prototype
.lstr
(
, <sourcetext>
) <count>
Return types
.nul, .inf, string
Description
Extracts characters from the beginning of a string
Parameters
sourcetext
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf , unless the second parameter is
.nul |
string
| The string to extract the beginning characters from |
count
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result is the whole first parameter |
integer
| The number of characters to extract. If this is negative no characters are returned. If it is greater than the length of the string then the whole string is returned |
.rstr()
Prototype
.rstr
(
, <sourcetext>
) <count>
Return types
.nul, .inf, string
Description
Extracts characters from the end of a string
Parameters
sourcetext
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf , unless the second parameter is
.nul |
string
| The string to extract the ending characters from |
count
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result is the whole first parameter |
integer
| The number of characters to extract. If this is negative no characters are returned. If it is greater than the length of the string then the whole string is returned |
.substr()
Prototype
.substr
(
, <sourcetext>
, <startpos>
) <count>
Return types
.nul, .inf, string
Description
Extracts characters a specified number of characters from a specified position in a string
Parameters
sourcetext
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf , unless another parameter is
.nul |
string
| The string to extract characters from |
startpos
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| If the result will be a string, then it will be the empty string, ie. the function behaves as if character extraction starts at the end of the string. |
integer
| The one-based position to start extracting characters from. If this is zero or negative then the start position is the start of the string. If it is greater than the length of the string then an empty string is returned. |
count
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| If the result is a string then all characters to the end of the string are extracted |
integer
| The number of characters to extract. If this is negative no characters are returned. If it is greater than the length from the start of the extraction to the end of the string then characters up to the end of the string are returned. |