I'll take it line-by-line and explain what it appears to be doing.
if { [regexp {index_(\d+)} $line all idx] } {
This first line checks to see if the string stored in line
includes
a substring of index_
followed by 1 or more digits. If so, it
stores the matching substring in all
(which the rest of the code
appears to ignore) and stores the digits found in the variable idx
.
So if line
were set to "stuff index_123 more stuff"
, you would end
up with all
set to index_123
and idx
set to 123
.
regsub {^[^"]*"} $line {} d
This regsub
will remove everything from the beginning of line
up
to and including the first double-quote. It stores the result in d
.
regsub {".*} $d {} d
The next regsub
operates on the value now in d
. It looks for a
double-quote and removes that character and everything afterward,
storing the result again in d
.
regsub -all {,} $d {} d
Finally, this line deletes any commas found in d
, storing the result
back in d
.
The next set of regexp
/regsub
lines perform a similar set of
operations except for the last line in the group:
regsub -all {[ ,]+} $d { } d
After the previous lines removed everything except the section that had been in double-quotes, this line removes any sections made up of one or more spaces and commas and substitutes them with a single space.
Let me know if that is clear.