Purpose

STRFIELD returns the sub string located between the nth-1 and nth occurrence for a specified delimiter.  
 

Syntax

variable = COUNT (operand1,operand2,operand 3{,operand 4})
 

Operation

operand1 is any valid alphanumeric string
operand2
 is any valid alphanumeric literal or variable specifying the delimiter to be used

operand 3
is the number of the occurrence of the sub-string required
operand 4
if present is the returned value depending upon the outcome of the process
variable
is any numeric variable
 

Remarks

The delimiter specified in operand 2 can more than one character.

If specified,
operand4 is updated with the character delimiter that was used to select the sub-string.
 

Example
 

$A = STRFIELD(“The:Quick:Brown”,“:”,1,$DELIM)....................gives $A = “The”

$A = STRFIELD (“The:Quick:Brown”,“:”,2,$DELIM)....................gives $A = “Quick”

$A = STRFIELD (“The:Quick:Brown”,“:”,3,$DELIM)....................gives $A = “Brown”

In the first two examples $DELIM is updated with “:".  In the last case $DELIM is returned as a null string, thereby providing an indicator that all of the string has been processed.

If operand 2 (the delimiter) is not found, all of operand 1 (the InString) is returned to $A.

If operand 2 (the delimiter) is a null string, a null string is returned.

If operand 3 (the numeric) is specified as 0, the first sub-string is returned.
 

 

Comment on this topic

Topic ID: 520122

 
 
 

Table of Contents

Index

Glossary

-Search-

Back