The implementation code of batch processing to judge whether special characters or not


Batch judge whether it is special character

Used to determine whether a character entered is a symbol in “& ^ >.
Note that spaces in the matching string cannot be omitted!

Batch code:

Copy codeThe code is as follows:
@echo off
set Input=S
set /p Input=Please input a number:
set Filter=S%Input%echo off >nul 2 >nul
rem replace ” with >
set Filter=%Filter:”=>%
echo %Filter%a
rem &
if “%Filter%”==”S ” echo and
rem ^
if “%Filter%”==”Secho off  2   ” echo fan
rem >
if “%Filter%”==”S off  2   ” echo gtr
echo %Filter%