The START I/O statement allows you the use of the WHILE LIKE clause.
With this clause it is possible to search records that match a regular expression pattern.
With regular expressions, the possibilities of patterns to be used for search are considerably expanded.
In this article we will explore on how to use that clause and the regular expressions power, in order to search on ISAM keys in case insensitive mode.
The search pattern will include "(?i)" in the beginning, to indicate that the search will be case insensitive. The word (or substring) to search will be enclosed within ".*" (before and after) in order to search for that word in any position of the key.
Move "(?i).*salt.*" to key-search-pattern
while key is like key-search-pattern.
The above will allow the program to read all records (on a reading loop) that have the word "SALT" on any case combination in any position of the record key.
Attached you will find the full example of this.
When this sample is run, it produces the following output: