[REBOL] Re: Upper-Lower Case
From: greggirwin:mindspring at: 13-Dec-2001 21:20
Hi Louis,
<< The text I need to convert is between tags >>
This isn't quite as concise as Allen's but it preserves the original
formatting (i.e. spacing) of the string. To meet your needs I added the
/with refinement.
proper-case: func [
"Capitalizes the first letter of each word in the string."
s [string!]
/with "specify delimiters other than space and tab."
delimiters [string! block!]
/local
i up-it result
][
if not with [delimiters: " ^-"]
result: lowercase copy s
up-it: true
for i 1 length? result 1 [
if up-it [
poke result i to-char uppercase to-string result/:i
up-it: false
]
if find delimiters result/:i [up-it: true]
]
return result
]
proper-case "gregg irwin"
proper-case/with "gregg irwin" " "
proper-case/with ">gregg>irwin" " >"
proper-case/with ">gregg irwin<" [#" " #"^-" #">"]
HTH!
--Gregg