Re: set character at string position
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: set character at string position

From: Bryan Oakley <oakley@bardo.clearlight.com>
Date: Fri Dec 30 2005 - 21:33:48 CET

Lisa Pearlson wrote:
> Hi,
>
> I looked at the string class, but I don't see how I can set/replace a
> character on a certain string position.
> In C I'd do something like:
>
> char s[] = "Hello";
> s[2] = 'x';
>
> This would give "Hexlo"
>
> How do I this in Tcl?
>
> Lisa
>
>

set s "Hello"
set s [string replace $s 2 2 x]
Received on Tue Jan 3 03:09:51 2006