INSPECT statement.

The INSPECT statement provides the ability to tally or replace occurrences of single characters or sequences of characters in a data item.

Format 1.

          INSPECT identifier-1 TALLYING  tallying-phrase

Format 2.

          INSPECT identifier-1 REPLACING replacing-phrase

Format 3.

          INSPECT identifier-1 TALLYING  tallying-phrase

                  REPLACING replacing-phrase

Format 4.

          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    }