In article <[email protected]> Peter wrote:

> This is some Friday fun with parsing with REXX. First I was baffled with
> the result, now I understand. So *no* I will not join the TSO/REXX list
> ;-)
> I've got a data set to process with REXX. The records are of format:
>
> "word1 word2.word3 word4:word5.word6 word7 hh.mm.ss"
> 
>
> What I need is each record split into:
>
> var1 = "word1"
> var2 = "word2.word3"
> var3 = "word4:word5.word6"
> var4 = "word7"
> var5 = "hh"
> var6 = "mm"
> var7 = "ss"
>
> Easy, I thought and coded:
>
> PARSE VAR input var1 var2 var3 var4 var5 "." var6 "." var7 .
>
>
> The result baffled me and was far from anything I understood at first.
> Here is what the variables look like:
>
>
> var1 ==> "word1"
> var2 ==> "word2"
> var3 ==> ""
> var4 ==> ""
> var5 ==> ""
> var6 ==> "word3 word4:word5"
> var7 ==> "word6"
>
>
> Have fun. 

It uses your literal "." as anchors.  Because those anchor characters appear
within the data as well as separating it, you have to isolate the fields
where they appear from the fields they punctuate first.

PARSE VAR input var1 var2 var3 var4 var8 .
PARSE VAR var8 var5 "." var6 "." var7 .

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to