On Wed, 26 Feb 2020 09:29:42 +1100, Wayne Bickerdike wrote:
>*Well, I wouldn't have used the same variable name as the test data, and
>it's not clear whether the period in 9.12 is fortuitous. Your parse won't
>work against, e.g., myVar = 'word1 word2 666 word3.ext'*
>
>I didn't use WORD3 in my test data. As for a fortuitous period in the test
>data, you work with what you are given.
>
>My less efficient solution is to use the REVERSE function.
>
>TRACE I
>MYVAR = 'WORD1 WORD2 9.12 XXXXZ.EXT'
>PARSE VALUE REVERSE(MYVAR) WITH EXT '.' WORD3 .
>
What if the fortuitous period occurs after the expected solution:
MYVAR = 'WORD1 WORD2 9.12 XXXXZ.EXT Fred.Smith'
It's easier when you know the answer in advance.
It's harder when the statement of the problem is incomplete,
or needs to be inferred from a single example.
If he's looking for an MS-DOS filename, an Expert System could
handle it. Or a regex.
-- gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN