| View previous topic :: View next topic |
| Author |
Message |
wiz(andrew) Voice
Joined: 01 Sep 2006 Posts: 5
|
Posted: Fri Sep 01, 2006 8:04 am Post subject: string editing |
|
|
hello
i need few proc/command that match mirc's commands $mid
| Code: | $mid(text,S,N)
Returns N characters starting at position S in text.
$mid(othello,3,4) returns hell
If N is zero, it returns the number of characters from S to the end of the line.
You may also use negative numbers for S or N. |
what i am trying to is to take out lets say the secound char from a string etc..
string "abc 123 qwe"
then to take the 2chr "b" or the 5 till the 8 "123 "
Thx For the help |
|
| Back to top |
|
 |
krimson Halfop

Joined: 19 Apr 2006 Posts: 86
|
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Fri Sep 01, 2006 10:28 am Post subject: |
|
|
Try:
| Code: | proc mid {text s {n ""}} {
if {[info exists n]} {
return "[string range $text [expr $s - 1] [expr $n - 1]]"
} else {
return "[string length [string range $text [expr $s - 1] end]]"
}
} |
Not tested. _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
wiz(andrew) Voice
Joined: 01 Sep 2006 Posts: 5
|
|
| Back to top |
|
 |
|