| 1. |
Solve : Parsing a string? |
|
Answer» I am SURE there is a simple method to do this but I am missing it. I want a batch FILE which will take an incoming variable, take it apart and put it together in a little bit different order. I might want to take the date string (Mon 05/26/2008) and reorder it as (2008\05\26). For any difference which it might make, I will be doing this under WinXP CMD. Thanks.you can extract part of a string as follows you forgot to mention the venerable for loop I didn't forget; I chose not to mention it, because I think it may be off putting to beginners and those seeking a simple concise solution. Of course, if the position of the desired substring(s) is/are not known exactly, and there are identifiable token delimiters, then FOR is very useful. I have noticed that many people seem to find FOR somewhat non-intuitive. mmcoy, if you hang around this forum, you will soon discover that ghostdog has a habit of jumping into threads where people have asked for a batch solution, and offering them a vbscript solution. I don't think he has shares in vbscript; I suspect he can't help it. I hesitate to criticize him seriously for it, because some of the solutions he offers are very elegant and sometimes better. I think he genuinely feels that vbscript code looks better than NT/XP/2K/Vista command language, which I think he considers to be crude and ugly. That is a matter of opinion, of course. I think everybody knows mine! Quote from: Dias de verano on May 26, 2008, 07:10:11 AM Quote from: ghostdog74 on May 26, 2008, 06:17:57 AMi mentioned it, because OP seems to want to manipulate the output of date. Therefore, the for loop with token/delimit may come in handy.The output of date has an unvarying, predictable structure, and i cannot see why one method of slicing it should be preferred to another, but I am willing to be persuaded.you forgot to mention the venerable for loop |
|