问题
I want to parse a file that looks like this using batch :
a: string_containing_various_characters,.:and spaces/1
b: string_containing_various_characters,.:and spaces/2
c: string_containing_various_characters,.:and spaces/3
d: string_containing_various_characters,.:and spaces/4
e: string_containing_various_characters,.:and spaces/5
f: string_containing_various_characters,.:and spaces/6
g: string_containing_various_characters,.:and spaces/7
I need to extract every string following "a: ","b: ","c: " etc... I can't use space as a delimiter since there can be spaces in the strings. The only thing that is always true is that the first ": " will always be where I want to cut the line.
Any ideas?
回答1:
try this:
for /f "tokens=1*" %%a in (file) do for /f "delims=:" %%c in ("%%~b") do echo %%c
来源:https://stackoverflow.com/questions/18278001/how-to-parse-a-file-with-special-delimiters-in-a-batch-file