Re: New question on strings



tom.rmadilo wrote:
On Feb 28, 6:51 am, "Gerald W. Lester" <Gerald.Les...@xxxxxxx> wrote:
mark wrote:
mark <jjoyce1...@xxxxxxxxxxx> dixit:
My string is
BSBSBSBSBSBSBSBS\Important_info.ars BSBSBSBSBSBS
Retrieve the info between .ars and the first backslah to the left.
Any ideas?
% set str {BSBSBSBSBSBSBSBS\Important_info.ars BSBSBSBSBSBS}
% 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|
+------------------------------------------------------------------------+
.