help with a script

Post Reply
User avatar
Thunderstone
Site Admin
Posts: 2504
Joined: Wed Jun 07, 2000 6:20 pm

help with a script

Post by Thunderstone »



greetings,

i need a little help with a script.

i want to capitalise the first letter of each word in a string... i've
tried a few things but i can't get the code out.

the code doesn't need to do anything tricky .. it only needs to upcase the
first character of the string and any character after a space.

anyone help?

thanks :)


| "Twitchy as a two legged : Byron Jones |
|| whippet." : Communications Manager ||
|| byronj@nd.edu.au : Notre Dame University ||
| http://www.nd.edu.au/byronj/ : Fremantle, Australia |




User avatar
Thunderstone
Site Admin
Posts: 2504
Joined: Wed Jun 07, 2000 6:20 pm

help with a script

Post by Thunderstone »




There's no direct way to uppercase individual characters of a string,
but you could use <sandr> to search for each letter and replace it
with the uppercase. To get the first character would require a slightly
different expression or you could just put a leading space on the
string for the <sandr> then remove it again.

<$srch=" a" " b" " c" ...the rest of the alphabet... " z" ">>= ">
<$repl=" A" " B" " C" ...the rest of the alphabet... " Z" "" >
...
<$a="this is a string">
<sum " %s" $a><sandr $srch $repl $ret>$ret

I hope you don't plan on doing that many times for each row. This is a
mildly intensive operation. Doing it too much could slow you down a bit.


Post Reply