Re: New question on strings
- From: "Gerald W. Lester" <Gerald.Lester@xxxxxxx>
- Date: Thu, 28 Feb 2008 11:08:32 -0600
tom.rmadilo wrote:
On Feb 28, 6:51 am, "Gerald W. Lester" <Gerald.Les...@xxxxxxx> wrote:mark wrote:mark <jjoyce1...@xxxxxxxxxxx> dixit:% set str {BSBSBSBSBSBSBSBS\Important_info.ars BSBSBSBSBSBS}My string isRetrieve the info between .ars and the first backslah to the left.
BSBSBSBSBSBSBSBS\Important_info.ars BSBSBSBSBSBS
Any ideas?
% set first [string first \\ $str]
% set end [string first .ars $str]
% set target [string range $str [incr $first] [incr $end -1]]
OMG, is this another one of those regressions? I guess so. [Incr] now
auto initializes to zero if the variable doesn't exist. I wonder how
many infinite loops will be caused by this one? Imagine if our best
programmers make this mistake, how hard it will be for a newbie to
figure out why this code doesn't work?
I assume that [incr $first] should be [incr first]?
No it was a cut/paste/correction error.
My test code actually was:
% string range $str $first $end
Which returned:
\Important_info.
In creating the reply, I added the incrs to get rid of the unwanted characters but forgot to take off the dollar signs. And needless to say, did not test the final post.
Please remember *most* of us do not answer c.l.t. questions as our primary job responsibility, so when one of us makes a typo -- cut us a little slack.
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.
- Follow-Ups:
- Re: New question on strings
- From: Glenn Jackman
- Re: New question on strings
- References:
- New question on strings
- From: mark
- Re: New question on strings
- From: mark
- Re: New question on strings
- From: Gerald W. Lester
- Re: New question on strings
- From: tom.rmadilo
- New question on strings
- Prev by Date: Re: tclhttpd with utf-8
- Next by Date: Re: serial communication with tcl
- Previous by thread: Re: New question on strings
- Next by thread: Re: New question on strings
- Index(es):