This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how to get 1st "X" chars from a string?

Old posts that have not been replied to for several years.
Locked
N
Nexus6
Op
Posts: 114
Joined: Mon Sep 02, 2002 4:41 am
Location: Tuchola, Poland

how to get 1st "X" chars from a string?

Post by Nexus6 »

Hey,

I have a word "example" and I wanna get 2 chars from the beginning so it would be "ex" or two fom the end so it would be "le" how can I do it in TCL?

Thanks in advance for help :)
K
Kingster

Post by Kingster »

Could try something like...

Code: Select all

[string range $string 3 4] == $another_string
The numbers after "string range $string" are the beginning and ending of the area to look...

But someone here might correct my syntax... I'm new at this as well... heheheheh...

{{EDIT}}
Wait... Just re-read what you were trying to do...

You can still use string range....

First two chars:

Code: Select all

set first_two [string range $string first 1]
Last two chars:

Code: Select all

set last_two [string range $string last-1 last]
Again. I could be wrong... just tryin to help you out here... :D
Locked