REXX – INDEX, POS, SUBSTR, COMPARE
Using REXX code, I want to find if a particular word is present in the provided input string. Which of the below functions will help in meeting the requirement.
EX: Word to be found: REXX
Input String: This question is based on REXX
Explanation for all the options is provided below.
A) INDEX: Returns the character position of the first character of a specified string found in the input string, otherwise 0.
PosNum = INDEX(StringToLookIn , StringtobeFound )
PosNum = INDEX(‘This question is based on REXX’, ‘REXX’ )
B) POS: Returns the character position of one string in another.
PosNum = POS(StringtobeFound, StringToLookIn)
PosNum = POS(‘REXX’,’This question is based on REXX’)
C) SUBSTR: Returns a portion of the input string beginning at a specified character position
So we can run a loop on the input string, and search for the word REXX in it.
D) COMPARE: Returns 0 if the two input strings are identical. Returns the position of the first character that does not match
Ex: COMPARE(‘ABC’,’ABC’) = 0
COMPARE(‘ABCD’,’ABC’) = 4
Here you can split the string into different words, and look into each word with the word
“REXX” that needs to be found using COMPARE function.
So all the options mentioned above can be used for the requirement.
In United States, If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog
You may also like to look at: