Upper-Lower Case
[1/6] from: louisaturk::coxinet::net at: 10-Dec-2001 1:55
Hi rebols,
There are the words uppercase and lowercase. I need an upper-lowercase.
x: upper-lowercase "THE BIG DOG IS A PIG"
>> "The Big Dog Is A Pig"
I know that "A" should be "a" for correct English. But this is not for the
English language, and I want to keep it simple.
Does anyone know a short, simple way to do this?
Louis
[2/6] from: rebol:optushome:au at: 13-Dec-2001 7:03
Use the /part refinement of Uppercase.
proper-case: func [value /local out][
out: copy ""
value: parse form value none
;probe value
foreach item value [
append out join uppercase/part lowercase item 1 " "
]
trim/tail out
]
foreach item ["the big do is a pig" "JOHN SmITH" "peter" #"a" "a b c"][print
proper-case item ]
Cheers,
Allen K
[3/6] from: louisaturk:eudoramail at: 13-Dec-2001 17:33
Hi Allen,
At 07:03 AM 12/13/2001 +1000, you wrote:
>Use the /part refinement of Uppercase.
>proper-case: func [value /local out][
<<quoted lines omitted: 10>>
>Cheers,
>Allen K
Many thanks for responding. Unfortunately, I gave a bad example
(sorry). The text I need to convert is between tags, in which case your
function fails on the first letter after each >.
>> x: {>THE BIG bad dog aTE tHe caT}
== ">THE BIG bad dog aTE tHe caT<"
>> proper-case x
== ">the Big Bad Dog Ate The Cat<"
>>
Louis
[4/6] 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
[5/6] from: louisaturk:eudoramail at: 14-Dec-2001 1:52
-- Unable to decode HTML file!! --
[6/6] from: louisaturk:eudoramail at: 14-Dec-2001 3:15
Hi Greg,
At 09:20 PM 12/13/2001 -0700, you wrote:
>To meet your needs I added the
>/with refinement.
<<quoted lines omitted: 22>>
> proper-case/with ">gregg>irwin" " >"
> proper-case/with ">gregg irwin<" [#" " #"^-" #">"]
Many thanks. That solves my problem, and I appreciate it very much. This
list really has a lot of great people on it.
Louis
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted