在批处理文件中解析字符串 [英] Parsing string in batch file

查看:103
本文介绍了在批处理文件中解析字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下字符串:

MyProject的/建筑= 32位,BuildType =调试,OS = winpc

我希望能够抓住值32位,调试和winpc并将它们存储在名为架构,BuildType变量和OS在批处理脚本日后参考。我通常在Unix的家伙,所以这是一个新的领域对我来说。任何帮助将大大AP preciated!

I would like to be able to grab the values 32bit, Debug, and winpc and store them in variables named Architecture, BuildType, and OS to reference later in the batch script. I'm normally a Unix guy so this is new territory for me. Any help would be greatly appreciated!

推荐答案

这应该这样做:

FOR /F "tokens=1-6 delims==," %%I IN ("MyProject/Architecture=32bit,BuildType=Debug,OS=winpc") DO (
    ECHO I %%I, J %%J, K %%K, L %%L, M %%M, N %%N
)
REM output is: I MyProject/Architecture, J 32bit, K BuildType, L Debug, M OS, N winpc

批处理循环是pretty有趣台机器。在控制台输入 FOR /?对于一些疯狂的东西它可以做一个说明。

The batch FOR loop is a pretty interesting piece of machinery. Type FOR /? in a console for a description of some of the crazy stuff it can do.

这篇关于在批处理文件中解析字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆