Batch File how to search for keywords from user input? -
is there way program can search keywords in user input? example if type in "hello, you?" tell said hello , says hello back.
a more flexible way (possibilty search several words (synonymes)) - here "hello", "hallo" , "hi" (but not "halloween" or "china"):
set input=hello, it's me echo %input% |findstr /i "\<h[ae]llo\> \<hi\>" >nul && echo hello set input=hallo, it's me echo %input% |findstr /i "\<h[ae]llo\> \<hi\>" >nul && echo hello set input=hi, it's me echo %input% |findstr /i "\<h[ae]llo\> \<hi\>" >nul && echo hello set input=it's halloween echo %input% |findstr /i "\<h[ae]llo\> \<hi\>" >nul && echo hello the last line gives no output, because searches whole words only.
see findstr /? explanations.
&& works "if previous command (findstr) successful then" (opposite ||)
Comments
Post a Comment