Module lessons (1/2)
STRING, UNSTRING and INSPECT
Concatenate fields by eliminating trailing blanks with DELIMITED BY SPACE, parse CSV with UNSTRING and count/replace patterns with INSPECT.
What you'll learn in this lesson
- Concatenate multiple fields by eliminating trailing spaces using
STRING ... DELIMITED BY SPACE / SIZE ... INTO ... END-STRING. - Separate delimited records (such as CSV fields or
"2026-11-15"dates) into individual variables usingUNSTRING ... DELIMITED BY ... INTO .... - Count characters and normalize strings in-place using
INSPECT ... TALLYINGandINSPECT ... REPLACING.
Overview
In modern languages first + " " + last automatically manages the length of strings; in COBOL WS-FIRST PIC X(15) containing "MARIO" physically has 10 trailing spaces ("MARIO "). This is where STRING, UNSTRING and INSPECT come into play.
The DELIMITED BY clause establishes where to stop the copy of each source:
Sections covered in this lesson
- 11. Smart concatenation with
STRING - 22. Reverse parsing with
UNSTRING - 33. Scan and normalize with
INSPECT - 44. Tracking the cursor index with
WITH POINTER - 5Try it yourself
Unlock "STRING, UNSTRING and INSPECT" and the full Course COBOL curriculum
Concatenate fields by eliminating trailing blanks with DELIMITED BY SPACE, parse CSV with UNSTRING and count/replace patterns with INSPECT.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course COBOL plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.