摘自:http://blog.51cto.com/lynnteng0/804520 describe="it's a describe by yourself" if echo "$describe" | grep -q '^[a-zA-Z0-9]\+$'; then echo "ok" else echo "invalid" fi describe="it's a describe by yourself"
利用正则. u4e00-u9fa5; //中文 ^[A-Za-z]+$ //英文字母 //截取冲击式样形状 public string SubStringForXingZhuang(string xingzhuangDetail) { int index = xingzhuangDetail.IndexOf('型'); ].ToString(); Match mInfo = Regex.Match(xing, @"^[A-Za-z]+$"); if (mInfo.Success
1.判断字符串为空 if [ -z "$str" ]; then echo "empty string" fi 2.判断文件是否存在 if [ -f /home/builder/.profile ]; then echo "File exists;" fi 3.逻辑非 if [ ! -f /home/builder/.bash_profile ]; then echo "here!"else echo "te
exeg Warning This function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0. function checkStr($str){ $output=''; $arr = array(); preg_match('/['.chr(0xa1).'-'.chr(0xff).']/', $str, $a, PREG_OFFSET_CAPTURE); preg_match('/[0-9]/', $str, $b, PREG
ok,以后最好是每天一个shell小脚本吧,这样以后工作时还可以直接套用,嗯,比较不错,顺便还可以带给刚入门shell的朋友一些帮助,好了,废话不多说,下面是我两种判断的实现方式: 1.通过grep去筛选非数字,判断其输出状态,以下两种方式: #!/bin/bashread -p "please input a num: " num if echo $num | grep -q '[^0-9]' then echo "this is not a num,please inpu
var p = /[0-9]/; var b = p.test(string);//true,说明有数字var p = /[a-z]/i; var b = p.test(string);//true,说明有英文字母var p = /[0-9a-z]/i; var b = p.test(string);//true,说明有英文字母或数字转自:https://zhidao.baidu.com/question/1962081645630822020.html