---
title: "COBOL really you need ideas to modify strings"
description: "Replace and Converting are to mostly used methods to modify string when you use INSPECT verb in COBOL. Read more."
url: https://srinimf.com/2016/06/01/cobol-examples-for-inspect-replacing-and-converting/
date: 2016-06-01
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/06/strings.jpg?fit=500%2C500&ssl=1
categories: ["COBOL"]
tags: ["Best COBOL performance tuning tips", "COBOL Inspect examples", "COBOL Tips and Tricks"]
type: post
lang: en
---

# COBOL really you need ideas to modify strings

The below are the selected examples for INSPECT replacing and INSPECT converting. Total I have given 3 examples.

Related[COBOL INSPECT these four top examples you need to try](https://srinimf.com/2012/06/03/cobol-inspect-verb-4-benefits/)

**Example for Replacing Single Letter:**

77 COUNTR PIC 9 VALUE ZERO.

01 DATA-2 PIC X(11).

. . .

INSPECT DATA-2

TALLYING COUNTR FOR LEADING “0”

REPLACING FIRST “A” BY “2” AFTER INITIAL “C”

**Example for Replacing Multiple Chars**

77 COUNTR PIC 9 VALUE ZERO.

01 DATA-3 PIC X(8).

. . .

INSPECT DATA-3

REPLACING CHARACTERS BY ZEROS BEFORE INITIAL QUOTE

**Example for INSPECT Converting:**

1 DATA-4 PIC X(11).

. . .

INSPECT DATA-4

CONVERTING

“abcdefghijklmnopqrstuvwxyz” TO

“ABCDEFGHIJKLMNOPQRSTUVWXYZ”

AFTER INITIAL “/”

BEFORE INITIAL”?”

Related[COBOL Strings, Here are Ideas (1 of 2)](https://srinimf.com/2010/04/07/mainframecobol-strings-inspectconcatenation-splitting1of2/)

### 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%2F2016%2F06%2F01%2Fcobol-examples-for-inspect-replacing-and-converting%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F06%2Fstrings.jpg%3Ffit%3D500%252C500%26ssl%3D1&description=COBOL%20really%20you%20need%20ideas%20to%20modify%20strings)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/06/01/cobol-examples-for-inspect-replacing-and-converting/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/06/01/cobol-examples-for-inspect-replacing-and-converting/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/06/01/cobol-examples-for-inspect-replacing-and-converting/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/06/01/cobol-examples-for-inspect-replacing-and-converting/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%20really%20you%20need%20ideas%20to%20modify%20strings&body=https%3A%2F%2Fsrinimf.com%2F2016%2F06%2F01%2Fcobol-examples-for-inspect-replacing-and-converting%2F&share=email)
-

### Like this:

Like Loading…
