解析一个动态大小的字符串 [英] Parse a dynamically sized string

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

问题描述

我有一个变量:

set myvar="26:deployment.javaws.jre.0.product=1.8.0_111"

我想在jre之后检索值.和.product,它们将是整数0.在此之间的值将始终是整数.该变量的字符串可能会稍有变化,但是[jre.] [integer] [.product]的格式将始终保持不变.因此,我不能只使用硬编码值来获取子字符串,因为如果说字符串开头的第一位数字是3位而不是2位长,那么字符串每次都可能不同,并且在开始处有更多字符.我该怎么办?

I want to retrieve the value after the jre. and .product which would be the integer 0. The value in between here will always be an integer. The variable can string can change slightly, but the format of [jre.][integer][.product] will always stay the same. Because of this I cant just get the substring using hardcoded values because the string may be different each time and have more characters at the beginning if say the first digit at the beginning of the string is 3 digits instead of 2 long. How can I do this?

推荐答案

for /f "tokens=5 delims=:." %%a in ("%myvar%") do echo -%%a-

尝试

这篇关于解析一个动态大小的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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