Code for PROGRAM TO FIND AND REPLACE USING INSPECT VERB in Cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. INSPECT-VERB.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 REC PIC X(80).
01 SEARCH-WORD PIC XXX.
01 REPLACE-WORD PIC XXX.
PROCEDURE DIVISION.
DISPLAY "ENTER THE SENTENCE..".
ACCEPT REC.
DISPLAY "ENTER THE WORD TO BE SEARCHED..".
ACCEPT SEARCH-WORD.
DISPLAY "ENTER THE WORD TO BE REPLACES..".
ACCEPT REPLACE-WORD.
INSPECT REC REPLACING ALL SEARCH-WORD BY REPLACE-WORD.
DISPLAY REC.
STOP-RUN.
/*******************************************************************************************
OUTPUT
********************************************************************************************/
ENTER THE SENTENCE..
HI
ENTER THE WORD TO BE SEARCHED..
I
ENTER THE WORD TO BE REPLACES..
H
HH