Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 如何检查某个字符串*是否以某个特定单词开始*在批处理中_String_Batch File - Fatal编程技术网

String 如何检查某个字符串*是否以某个特定单词开始*在批处理中

String 如何检查某个字符串*是否以某个特定单词开始*在批处理中,string,batch-file,String,Batch File,如何检查某个字符串(记录的文本文件中的行)是否以特定单词批开始 我知道如何检查句子/行(字符串)中是否存在单词(子字符串), 但是我怎样才能检查它是否以这个词开头呢 谢谢:)这可以用FINDSTR这样做: FINDSTR "^searchterm" 可以指定要搜索的源: 作为参数: FINDSTR /I "^searchterm" filename 使用管道: command | FINDSTR /I "^searchterm" 以上内容将仅搜索指定目录中的文件。要搜索整个树,即包括所

如何检查某个字符串(记录的文本文件中的行)是否以特定单词批开始

我知道如何检查句子/行(字符串)中是否存在单词(子字符串), 但是我怎样才能检查它是否以这个词开头呢


谢谢:)

这可以用
FINDSTR
这样做:

FINDSTR "^searchterm"
可以指定要搜索的源:

  • 作为参数:

    FINDSTR /I "^searchterm" filename
    
  • 使用管道:

    command | FINDSTR /I "^searchterm"
    
    以上内容将仅搜索指定目录中的文件。要搜索整个树,即包括所有子目录,请添加
    /S
    开关:

    FINDSTR /I "^searchterm"
    
    FINDSTR /I /S "^searchterm" D:\path\to\files*.ext
    
    FINDSTR/I/S“^searchterm”D:\path\to\files*.ext
    
    在内置帮助中可以找到其他有用的选项(运行
    FINDSTR/?

    FINDSTR /I "^searchterm" D:\path\to\files*.ext
    
    FINDSTR /I /S "^searchterm" D:\path\to\files*.ext