[REBOL] Re: can't quite get it right...
From: greggirwin:starband at: 6-Sep-2001 22:15
Hi Ryan,
I'm not sure if you wanted to replace upper or lower chars with the charset.
I'm a newbie and, to me, your code was doing the reverse of what your text
said. Anyway...here's a solution which, hopefully, is better than no
solution. Maybe a real REBOL will show us both a better way.
is-upper-char: func [ch[char!]][
either all [(ch >= #"A") (ch <= #"Z")]
[return true]
[return false]
]
upper-lower-char-repl: func [s[string!] /local new-s up-ch][
new-s: make string! length? s
foreach ch s [
up-ch: uppercase copy to-string ch
either is-upper-char ch
[append new-s ch]
[append new-s rejoin [{[} up-ch ch {]}]]
]
return new-s
]
upper-lower-char-repl "ABC"
upper-lower-char-repl "abc"
--Gregg