如果字符串中有空格,则批量关闭? [英] Batch closing if a string has a space in it?

查看:65
本文介绍了如果字符串中有空格,则批量关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以出于某种原因

set /p content="[-]"
timeout 1 >nul
if %content% == Quit goto QQIITT
if %content% == quit goto QQIITT
if %content% == Help goto HALPP
if %content% == help goto HALPP
timeout 1 >nul

如果我在程序中键入"echo HELLO"之类的内容将不起作用,那么当我键入带有空格的内容时,它会执行此操作,有没有人可以帮助您? (我正在制作一个批处理代码编辑器,如果它与if语句不匹配,它将进入保存更改的脚本)

if I type something like "echo HELLO" (in the program) it will not work, it does this when ever i type something with a space, is there anyone who can help? (I am making a batch code editor and if it does not match the if statements it will go to a script that saves the changes)

推荐答案

尝试一下

"%content%" == "Quit"

请注意,如果您在输入中输入双引号,则会导致中断.

Note this will break if you pass through a double quote in your input.

批处理盲目替换变量,因此在您的示例中代码呈现为

Batch blindly replaces variables so in your example the code renders as

if echo HELLO == HELP

这篇关于如果字符串中有空格,则批量关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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