gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 09:59:19 25 4
gpt4 key购买 nike

我有这个字符串代码:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com