检查变量是否在BATCH中包含一段文本 [英] Check if variable contains a piece of text in BATCH

查看:41
本文介绍了检查变量是否在BATCH中包含一段文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

变量=%version%

Variable = %version%

此变量包含= 5.13-update_01-01-2014

This variable contains this = 5.13-update_01-01-2014

如何使用IF语句检查变量%version%是否包含单词' update '?

How can use the IF statement to check if the variable %version% contains the word 'update' ??

谢谢你!

推荐答案

使用条件语句的简单演示.

A simple demo using conditional statements.

请参阅此帖子(dbenham的答案)以寻求类似的问题

Look at this post (dbenham's answer) for a similar question How to conditionally take action if FINDSTR fails to find a string

C:\>set variable=5.13_01-01-2014

C:\>(echo %variable% | findstr /i /c:"update" >nul) && (echo Variable contains the string "update") || (echo Variable does not have the string "update")
Variable does not have the string "update"

C:\>set variable=5.13-update_01-01-2014

C:\>(echo %variable% | findstr /i /c:"update" >nul) && (echo Variable contains the string "update") || (echo Variable does not have the string "update")
Variable contains the string "update"

干杯,G

这篇关于检查变量是否在BATCH中包含一段文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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