本文介绍了如何在批处理文件中解析带有特殊定界符的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用批处理来解析一个看起来像这样的文件:
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
我需要提取"a:","b:","c:"等后面的每个字符串.由于字符串中可以有空格,因此我不能使用空格作为定界符.唯一正确的是,第一个:"将始终是我要剪切的位置.
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.
有什么想法吗?
推荐答案
尝试一下:
for /f "tokens=1*" %%a in (file) do for /f "delims=:" %%c in ("%%~b") do echo %%c
这篇关于如何在批处理文件中解析带有特殊定界符的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!