如何使用批处理实现查找部分字符串

2025-04-13 05:21:01
推荐回答(1个)
回答1:

你是指的查找字符串中是否包含你要找的内容吧?
其实find是可以的,下面是一个例子

@echo off
setlocal enabledelayedexpansion
set mystr=helloworldjavacsharpminiipad
set something1=worl
set something2=jar

echo %mystr%>temp.tmp
find "%something1%" temp.tmp>nul
if !errorlevel! EQU 0 (echo found %something1%) else (echo not found %something1%)

find "%something2%" temp.tmp>nul
if !errorlevel! EQU 0 (echo found %something2%) else (echo not found %something2%)

del temp.tmp