How to parse a file with special delimiters in a b

2020-05-06 17:05发布

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条回答
孤傲高冷的网名
2楼-- · 2020-05-06 17:20

try this:

for /f "tokens=1*" %%a in (file) do for /f "delims=:" %%c in ("%%~b") do echo %%c
查看更多
登录 后发表回答