I have a string for which I wish to tally the count of characters till a certain pattern of characters is found.
For example:
Give a string: askabanskarkartikrockstar
I would like to know how many characters are there before the kartik
in the string.
In a normal scenario where I need to find the number of characters before, say k
, in the given string, I would write the code somewhat as:
INSPECT WS-INPUT-STRING TALLYING CT-COUNTER FOR CHARACTERS BEFORE LT-K
Where
WS-INPUT-STRING
is alphanumeric with a value ofaskabanskarkartikrockstar
,CT-COUNTER
is the counter used to count the number of charactersLT-K
is a literal with the valuek
.
But here, if I wish to do the same for a sub-string, like kartik
in the above example, would replacing the value of LT-K
with kartik
instead of just k
work? If yes, is the same applicable for alphanumeric literals that have values in the form of hexadecimal numbers (for example, in a literal X(02)
one stores a new-line character as x'0D25'
)?
I'm trying to implement the above code in zOS IBM mainframe v10. Thanks.