如何检查字符串不与批数字开始? [英] How to check a string does not start with a number in Batch?
本文介绍了如何检查字符串不与批数字开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何检查字符串的第一个字符是字母,因此它不是一个数字,或者更确切地说,一个密码?有此字符串中没有空格或特殊字符。
How can I check that the first character of a string is a letter and so that it is not a number, or rather a cipher? There are no spaces or special characters in this string.
推荐答案
我觉得这是最简单的方法:
I think this is the simplest way:
@echo off
setlocal EnableDelayedExpansion
set digits=0123456789
set var=1something
if "!digits:%var:~0,1%=!" neq "%digits%" (
echo First char is digit
) else (
echo First char is not digit
)
var的第一个字符是试图从数字
字符串中删除。如果这样的字符是一个数字,数字
字符串的变化;否则,数字
字符串保持不变。
The first character of var is tried to be removed from digits
string. If such a char was a digit, digits
string change; otherwise, digits
string remains the same.
这篇关于如何检查字符串不与批数字开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文