ids: ["AH-1-1" "AH-1-1G" "AH-1-G1"]
digit: charset "0123456789"
else: complement digit

rule: [any else here: copy n some digit there: 
(change/part :here 1 + load n :there)
]
foreach id ids[parse find/last id "-" rule] 

print ids


; ids are in a block of strings
; incremented part is after last hyphen
; incremented natural numbers never get shorter


On 9/1/05, Ed O'Connor <[EMAIL PROTECTED]> wrote:
> 
> 
> This string processing exercise is taken from the post:=20
> 
> http://discuss.joelonsoftware.com/default.asp?design.4.195596.22
> 
> Begin //////////////////////////
> 
> Given a text number of the follwing format:
> 
> AH-1-1
> Or=20
> AH-1-1G
> Or
> AH-1-G1
> 
> During data entry, we want the number code of the last part (token) to
> increment by one.
> 
> So, if you pass the above values, you get
> 
> AH-1-1 --> AH-1-2 --> AH-1-3
> AH-1-1G --> AH-1-2G --> AH-1-3G
> AH-1-G1 --> AH-1-G2 --> AH-1-G3
> 
> ////////////// End
> 
> I posted a REBOL version, but I'm not terribly gifted at writing parse
> rules. I'd be curious to see how other REBOLers might handle it.
> 
> Of course, if you have an approach that is elegant and/or terse, reply
> to the orginal poster.
> 
> Regards,
> Ed
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com <http://rebol.com> with unsubscribe as the subject.
> 
> 


-- 
... nice weather eh

-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to