The INSPECT statement counts or replaces occurrences of single
characters or groups of characters in a data item.
Format 3 -
INSPECT src-string TALLYING
{
{ tally-ctr FOR
{
{
{ [ { BEFORE } ] } }
{ CHARACTERS [ { AFTER } INITIAL delim-val ] ... } ... } ...
{ { ALL } {
{ { LEADING } { compare-val
{
[{ BEFORE } ] } } }
[{ AFTER } INITIAL delim-val ] ... } ... } ... } ...
REPLACING
{ CHARACTERS BY replace-char [{ BEFORE } INITIAL delim-val] ... }
{ [{ AFTER } ] }
{ { ALL } } ...
{ { LEADING } { compare-val BY replace-val
{ { FIRST }
[ { BEFORE } INITIAL delim-val ] ... } ... }
[ { AFTER } ] } }
1 – src-string
is the identifier of a group item or an elementary data item with DISPLAY usage. INSPECT operates on the contents of this data item.
2 – tally-ctr
is the identifier of an elementary numeric data item.
3 – compare-val
is the character-string INSPECT uses for comparison. It is a nonnumeric literal (or figurative constant other than ALL literal) or the identifier of an elementary alphabetic, alphanumeric, or numeric data item with DISPLAY usage.
4 – delim-val
is the character-string that delimits the INSPECT operation. Its content restrictions are the same as those for compare-val.
5 – replace-char
is the one-character item that replaces all characters. Its content restrictions are the same as those for compare-val.
6 – replace-val
is the character-string that replaces occurrences of compare-val. Its content restrictions are the same as those for compare-val.