Re: How to iterate through a (semicolon;separated;list)
From: Marty List (Bill.Gates_at_sun.com)
Date: 05/21/04
- Next message: Marty List: "Re: CPAU Updated"
- Previous message: Jim Davis: "Re: How to through a semicolon separated list in a string"
- In reply to: Csaba Gabor: "How to iterate through a (semicolon;separated;list)"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 21 May 2004 15:50:28 -0600
"Csaba Gabor" <news@CsabaGabor.com> wrote in message
news:eN6SYh2PEHA.2520@TK2MSFTNGP11.phx.gbl...
> Aaarggghh, sorry about the messed up title of my earlier post.
> In the meantime, I have an answer, but it is not wholly satisfying
> so I am modifying my question to ask whether there is any
> command line 'replace string'?
>
> The original question was to find out how I can iterate through
> a list of semicolon separated values (where the list was coming
> from a rows of a database). Here is my batch file solution:
>
> FOR /F "tokens=1,* delims=:" %%G ^
> IN ('c:\sqlite.exe c:\Mydb^
> "SELECT Id||':'||myList FROM myTable;"')^
> DO @FOR %%K IN (%%H) DO @ECHO %%G-^>%%K
>
>
> But I am getting lucky with that inner FOR loop. Really
> I would like to have a (regular expression preferred)
> 'replace string' in my arsenal.
>
> Thanks for any tips,
> Csaba Gabor
>
This doesn't support regular expressions, but the only thing built-in to the
OS that I can think of is %name:a=b% syntax. This is from SET /?:
===================================================
%PATH:str1=str2%
would expand the PATH environment variable, substituting each occurrence
of "str1" in the expanded result with "str2". "str2" can be the empty
string to effectively delete all occurrences of "str1" from the expanded
output. "str1" can begin with an asterisk, in which case it will match
everything from the begining of the expanded output to the first
occurrence of the remaining portion of str1.
===================================================
You don't need to use the SET command, you can do it on the fly:
Echo %WINDIR:C:=D:%
- Next message: Marty List: "Re: CPAU Updated"
- Previous message: Jim Davis: "Re: How to through a semicolon separated list in a string"
- In reply to: Csaba Gabor: "How to iterate through a (semicolon;separated;list)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|