Hoopy frood
Joined: Dec 2002
Posts: 2,884 |
A property for $replace to behave like that would be nice. If all you want to do is replace single characters like that though then the scripted version is quite simple really: char_replace {
; Usage: $char_replace(string,char,newchar,...,charN,newcharN)
var %i = 2, %j = 3, %c = 1
bset -t &string 1 $1
while $eval($+($,%j),2) != $null {
bset &chars %c $asc($eval($+($,%i),2)) $asc($ifmatch)
inc %i 2
inc %j 2
inc %c 2
}
breplace &string [ $bvar(&chars,1-) ]
return $bvar(&string,1-).text
} //echo $char_replace(this is just an example,a,b,b,c,c,d,d,e,e,f,f,g,g,h,h,i,i,j,j,k,k,l,l,m,m,n,n,o,o,p,p,q,q,r,r,s,s,t,t,u,u,v,v,w,w,x,x,y,y,z,z,a)echoes uijt jt kvtu bo fybnqmfRemember that only works for replacing single characters though.
|