The INSPECT statement provides the ability to tally or
replace occurrences of single characters or sequences of characters in
a data item.
INSPECT identifier-1 TALLYING tallying-phrase
INSPECT identifier-1 REPLACING replacing-phrase
INSPECT identifier-1 TALLYING tallying-phrase
REPLACING replacing-phrase
INSPECT identifier-1
CONVERTING { identifier-6 } TO { identifier-7 }
{ literal-6 } { literal-7 }
[ after-before-phrase ]
tallying-phrase.
{ CHARACTERS [ after-before-phrase ] }
{ identifier-2 FOR { { ALL } { { identifier-3 } [ after-before-phrase ] } ... } ... } ...
{ LEADING } { literal-3 }
replacing-phrase.
{ CHARACTERS BY { identifier-5 } [ after-before-phrase ] }
{ literal-5 }
{ { ALL } { identifier-2 } BY { identifier-5 } [ after-before-phrase ] }
{ LEADING } { literal-2 } { literal-5 }
{ FIRST }
after-before-phrase.
{ AFTER } [ INITIAL ] { identifier-4 }
{ BEFORE } { literal-4 }