$return = GetStringAt(string,start[,min_length,[,[\]left_delimiter[,[\]right_delimiter]]][,LEFTWILDCARDS | RIGHTWILDcARDS | USEWILDCARDS] )
Where:
$return | the delimited string extracted from the input string. |
string | the input string. |
start | the starting position within the input string. |
min_length | the search for the right delimiter begins at the starting position plus the min_length. The default min_length is 1. |
left_delimiter: | the left delimiter. The left delimiter can be a single character delimiter, a string of single character delimiters or a string delimiter. If a string of single characters is used, any one of the characters will act as the delimiter. To identify the entire string as the delimiter, you precede the string with a backslash. Enclose the left_delimiter in double quotation marks ("") if it contains embedded spaces or commas. If you are using a backslash to indicate a delimiter string and the string must be enclosed in double quotes, the backslash must be the first character following the opening double quote. The default left delimiter is a space. When the "LEFTWILDCARDS" or "USEWILDCARDS" parameter is specified, this parameter may contain wildcards and a pattern matching search is done for the delimiter. |
right_delimiter: | the right delimiter string. The right delimiter can be a single character delimiter, a string of single character delimiters or a string delimiter. If a string of single characters is used, any one of the characters will act as the delimiter. To identify the entire string as the delimiter, you precede the string with a backslash. Enclose the right_delimiter in double quotation marks ("") if it contains embedded spaces or commas. If you are using a backslash to indicate a delimiter string and the string must be enclosed in double quotes, the backslash must be the first character following the opening double quote. The default right delimiter is a space. When the "RIGHTWILDCARDS" or "USEWILDCARDS" parameter is specified, this parameter may contain wildcards and a pattern matching search is done for the delimiter. |
LEFTWILDCARDS | use pattern matching for the left_delimiter. |
RIGHTWILDCARDS | use pattern matching for the right_delimiter. |
USEWILDCARDS | use pattern matching for both the left_delimiter and the right_delimiter. |
The following wildcards may be used for pattern matching in the delimiters:
Wildcard Characters |
Matches in the search string |
? |
Any single character |
* |
Zero or more characters |
# |
Any single numeric digit |
[charlist] |
Any single character in charlist |
[!charlist] |
Any single character not in charlist |
charlist is a group of one or more characters enclosed in brackets ([]) and can be used to match any single character in a string. It may include any of the following characters:
• | Almost any character in the ANSI character set including digits |
• | The special characters opening bracket ([), question mark (?), number sign (#) and asterisk (*) can be used for matching only if enclosed in brackets. The closing bracket (]) can't be used within a charlist to match itself, but it can be used outside the group as an individual character. A hyphen (-) can be used at the beginning or end of charlist to match itself. In any other position it indicates a range of characters. |
• | A range of characters can be specified by placing a hyphen between lower and upper bounds. For example, [a-z], [A-Z] or [0-9]. Multiple ranges can be specified without any delimiter. For example [a-zA-Z0-9] matches any alphanumeric character. When a range of characters is specified they must appear in ascending sort order. [A-Z] is valid, but[Z-A] is not. |
string, start, min_length, left_delimiter and right_delimiter may be variables.
The GetStringAt command extracts a delimited string from an input string. If the start position is greater than zero, the input string is searched backwards for the left delimiter. If the start position is zero, the search for the left delimiter starts at the beginning and the input string is searched forward for the left delimiter. If the left delimiter is found, the command extracts characters starting at the first character following the left delimiter character or string. If the left delimiter is not found, the text from the input string is extracted starting at the first character. Extraction continues until the right delimiter is found. If the right delimiter is not found, the text from the input string is extracted until the end of string is reached. If neither delimiter is found, the entire string is returned.
Examples
$Word = GetStringAt("Every good boy does fine.",7,4)
$DollarAmount = GetStringAt("$100.00",1,1,"$",".")
$Quantity = GetStringAt("Sample size: 500. ",14,1,": ",". ")
$Words = GetStringAt("Every good boy does fine.",1,1,"\Every ","\ fine")
Sample Script
' GetStringAt.txt
' Sample script to display "good boy"
'
$Sentence = "Every good boy does fine"
$Start = Find($Sentence, "good")
$Result = GetStringAt($Sentence,$Start,5)
Msgbox($Result)
exit
See Also:
TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.