windows - 批量字符串问题(搜索整行)

标签 windows string batch-file text cmd

我有这个字符串代码:

set search=123
findstr /m %search% text.txt
if %errorlevel%==0 (
echo YES
) else (
echo NO
)

文本文件是这样的:

123
456
789

它有效,但如果我搜索为“1”,它会说"is",但我希望它只对整行说"is"。谁能帮忙。

最佳答案

 findstr /m ^%search%$ text.txt

你需要一个正则表达式。

来自 findstr 帮助

^ Line position: beginning of line

$ Line position: end of line

关于windows - 批量字符串问题(搜索整行),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22881265/

相关文章:

windows - 使用资源管理器上下文菜单将文件路径的修改版本复制到剪贴板

c++ - 用自身初始化字符串 (C++)

c++ - C++ 2013 中的 Dll 需要将字符串返回给 VB.net

c# - 自己的 C# 应用程序中的 Windows Aero 区域

c++ - EXE 或 DLL 镜像基址

windows - Windows RT 中的 Powershell 命令

java正则表达式删除csv中不需要的双引号

windows - 如果...或如果...在 Windows 批处理文件中

windows - 如何在批处理文件中的for循环中做可变长度的子字符串?

arrays - 如何为键=值项目批量遍历数组