On 2020-02-24, at 13:43:52, Ambros, Thomas wrote: > > A trivial item, but this surprised me. > > I wanted to parse out the string 'word3' using the period as a place holder. > The input could have a blank delimited string containing an embedded period > before the one I wanted to parse out. The Parse Var as coded didn't work. > ... > > myVar = 'word1 word2 9.12 word3.ext' > Parse Var myVar . . . myVal '.' . > ... > Say 'myVal=' myVal > ... The simple answer to the elliptically stated problem is: MyVal = 'word3'
A more general solution, using regex is: 556 $ echo 'word1 word2 9.12 word3.ext' | sed 's/.* \([^.]*\).*/\1/' word3 557 $ This finds the last substring in the subject preceded by a space and followed by a period. Full disclosure, for Tony to gloat: o It's easier to code than to review. o I got it right on the third try. o I haven't fuzz tested. -- gil ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN