---
title: "COBOL INSPECT these four top examples you need to try"
description: "INSPECT in COBOL is frequently used function to handle or manipulate strings. The given popular examples really good to use in your project."
url: https://srinimf.com/2012/06/03/cobol-inspect-verb-4-benefits/
date: 2012-06-03
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2012/06/cobol-1.jpg?fit=500%2C500&ssl=1
categories: ["COBOL"]
tags: ["COBOL Inspect examples", "COBOL Tips and Tricks"]
type: post
lang: en
---

# COBOL INSPECT these four top examples you need to try

The below are top four COBOL ‘INSPECT’ examples. These you can use directly into your project.

Related[COBOL and SQL – Replace Command](https://srinimf.com/2012/07/06/cobol-and-sql-replace-command/)

## Top Advantages

### **Benefit-1:**

With [INSPECT verb](https://srinimf.com/2010/04/07/mainframecobol-strings-inspectconcatenation-splitting1of2/) you can [convert lower case](https://srinimf.com/2013/04/04/mainframe-sort-overlay/) characters to upper case:

### **Benefit-2:**

Secondly, it counts all the letters in an array:

```
PERFORM VARYING idx 1 BY 1 UNTIL idx > 100

   INSPECT text-one  TALLYING COUNT1(idx) FOR ALL LETTER1(idx)

END-PERFORM
```

All the letters in LETTER1 table counted into Count1.

### **Benefit-3:**

Thirdly, REPLACING as needed one or multiple letters in output string.

```
INSPECT text-two REPLACING ALL "H" BY "K"
        AFTER INITIAL "C" BEFORE INITIAL "O".
```

### **Benefit-4:**

Replacing also works, to replace only if found 4 letter word:

**Example:**

```
PERFORM VARYING idx FROM 1 BY 1 UNTIL idx > 100
INSPECT text-three REPLACING testable(idx) BY "1234"
END-PERFORM
```

> There are many other usages. In my next post, I will discuss about problems that we meet in daily use.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2012%2F06%2F03%2Fcobol-inspect-verb-4-benefits%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2012%2F06%2Fcobol-1.jpg%3Ffit%3D500%252C500%26ssl%3D1&description=COBOL%20INSPECT%20these%20four%20top%20examples%20you%20need%20to%20try)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2012/06/03/cobol-inspect-verb-4-benefits/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2012/06/03/cobol-inspect-verb-4-benefits/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2012/06/03/cobol-inspect-verb-4-benefits/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2012/06/03/cobol-inspect-verb-4-benefits/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%20INSPECT%20these%20four%20top%20examples%20you%20need%20to%20try&body=https%3A%2F%2Fsrinimf.com%2F2012%2F06%2F03%2Fcobol-inspect-verb-4-benefits%2F&share=email)
-

### Like this:

Like Loading…
