Absent a problem description, there's no way to tell whether that does what the 
OP wants; does he want to treat the last word containing a period as fn.fext, 
or the fourth word? Does he want to allow multiple periods in the name, e.g., 
foo.bar.text? I could write a regex for any of these, but not without knowing 
which, if any, of them is correct.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List [IBM-MAIN@LISTSERV.UA.EDU] on behalf of 
Paul Gilmartin [0000000433f07816-dmarc-requ...@listserv.ua.edu]
Sent: Tuesday, February 25, 2020 10:41 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Rexx parse using period as placeholder

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

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to