JG+ 检查字符串
檢查字符串,要求必須包含數(shù)字和字母
代碼 //-----------------------------------------------------------------------------------------------------int AllNum(char *str)
{
int i,nLen;
nLen=strlen(str);
for (i=0;i<nLen;i++)
{
if (isalnum(str[i])==0)
return (0);
}
return (1);
}
//-----------------------------------------------------------------------------------------------------
int AllDigit(char *str)
{
int i,nLen;
nLen=strlen(str);
for (i=0;i<nLen;i++)
{
if (str[i]<'0' || str[i]>'9')
return (0);
}
return (1);
}
//-----------------------------------------------------------------------------------------------------
int AllPha(char *str)
{
int i,nLen;
nLen=strlen(str);
for (i=0;i<nLen;i++)
{
if (isalpha(str[i])==0)
return (0);
}
return (1);
}
//------int CheckBarcode(char *szBarcode)------------------------------------------------------------------------------
int CheckBarcode(char *szBarcode)
{
int nLen;
nLen=strlen(szBarcode);
if(nLen<2 || nLen> 13)
return 0;
if(AllNum(szBarcode))//只有數(shù)字或字母,沒(méi)有其他符號(hào)
{
if(AllPha(szBarcode))//純字母
return 0;
else if(AllDigit(szBarcode))//純數(shù)字
return 0 ;
else
return 1;
}
else
{
return 0;
}
}
?
?
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/clover-sheep/archive/2010/08/25/1808194.html
總結(jié)
- 上一篇: QTP中使用ExecuteFile加载v
- 下一篇: 【原】Ubuntu中安装 mercuri