1.

Solve : Token replacement/removal within delimited string?

Answer»

Is token replacement/removal within a delimited string possible within a batch file?

If I had a comma delimited string: a,b,c,D,e,f,g

Could I tell a batch file to replace, for example, D with h, leaving the REST of the string alone?

ThanksI suppose no one here has ever had a need for this. It is perfectly possible. You can easily use FOR to read the comma delimited string, and then write out the tokens again, substituting another substring for the 4th token.What I was hoping to avoid was having to deconstruct the string and rebuild it every time. The thought was maybe someone knew of a logical process or some command which could be used to rewrite a specific token in the string, sort of the opposite of what the For /F would do when it reads a specific token. Looking back on my initial post, I was vague, and I apologize. I'm just going to have to write a deconstruct/reconstruct process, which will work, albeit lengthy. Suppose I was just being lazy, hoping for an easier way.

Thanks again.Quote from: gregory on January 13, 2009, 02:44:55 AM

What I was hoping to avoid was having to deconstruct the string and rebuild it every time.

Why? This is the kind of task that computers are good at.
Quote from: Dias de verano on January 13, 2009, 02:50:43 AM

Why? This is the kind of task that computers are good at.


Because I have to write the code for it to work. half of everything is work.Quote from: BC_Programmer on January 13, 2009, 03:10:53 AM
half of everything is work.

What's the other half?Quote from: gregory on January 13, 2009, 03:13:43 AM
Quote from: BC_Programmer on January 13, 2009, 03:10:53 AM
half of everything is work.

What's the other half?

Thinking
I would have been so tempted to say "fate".I was thinking of the definition of genius, I think, 1% inspiration, 99% perspiration.

why not use set ? easier i think Quote from: devcom on January 13, 2009, 12:51:05 PM
why not use set ? easier i think

read his question again. the item to be replaced is neither at an ABSOLUTE position nor a KNOWN size, so for would be needed.


Quote from: devcom on January 13, 2009, 12:51:05 PM
why not use set ? easier i think

Give US some example code, then...

Here's the original question, to refresh your memory. Read it carefully.

Quote
Is token replacement/removal within a delimited string possible within a batch file?

If I had a comma delimited string: a,b,c,D,e,f,g

Could I tell a batch file to replace, for example, D with h, leaving the rest of the string alone?


Discussion

No Comment Found