Hi all,
I wanted a script that will take a string and capitalise the beginning of each word in the string.
i.e /begin_caps 'hello how are you' will return 'Hello How Are You'
I have now created a script, that works, but it uses a loop and feels really bulky and inefficient. I have not scripted in a whole long time, and I was hoping someone would improve on it.
I am sure some of you will come up with some really clever regexes, but could you also show some non-regex methods, so that I can understand them too.
I paste my script below.
alias begin_caps {
var %i = 1,%line = $1-,%result
while ($gettok(%line,%i,32)) {
var %x = $v1
%result = %result $upper($left(%x,1)) $+ $right(%x,$calc($len(%x) - 1))
inc %i
}
$iif($isid,return,echo -a) %result
}