答复: [cpp] 判断一个字符串格式,正则表达式?
李辉
lihui at coship.com
Thu Apr 5 15:46:14 CST 2007
hello world:123.456/789
hello:123.456/789world
等各种情况是否合法?
实在没有好办法,一个字母一个字母的while (*c++)也不会太麻烦:)
李辉
26733800-6153
-----邮件原件-----
发件人: cpp-bounces at codingnow.com [mailto:cpp-bounces at codingnow.com] 代表
Yang WeiQin
发送时间: 2007年4月5日 15:28
收件人: C++ Discuss Group
主题: Re: [cpp] 判断一个字符串格式,正则表达式?
少写一个参数
char x[1024];
int a;
if (4!=sscanf(str,"%s:%d.%d/%d",x,&a,&a,&a))
{
//print error
}
在 07-4-5,Yang WeiQin<yangweiqin at gmail.com> 写道:
> char x[1024];
> int a;
> if (4!=sscanf("%s:%d.%d/%d",x,&a,&a,&a))
> {
> //print error
> }
>
> 在 07-4-5,Fei Xu<flyingxu at gmail.com> 写道:
> > 我想对输入做个判断,如果不是 字母:数字.数字/数字
> > 就提示错误
> >
> > 上面这个怎么实现?我大概知道该用正则表达式,但是是不是要引入专门的编程
库?
> > 简单的用c/MFC语言内建的函数,怎么实现?
> >
> > _______________________________________________
> > Cpp mailing list
> > Cpp at codingnow.com
> > http://codingnow.com/mailman/listinfo/cpp
> >
>
_______________________________________________
Cpp mailing list
Cpp at codingnow.com
http://codingnow.com/mailman/listinfo/cpp
******声明******
本邮件及其附件所包含的信息均属深圳市同洲电子股份有限公司商业秘密,仅限于指定的个人或组织使用,未经许可,不得泄露给任何第三方。如果您不是本邮件的预期收件人,请立即将此错误告知本发件人,并迅速永久性删除本邮件及附件的所有原始件、复制件和输出件,请勿保存、复制、利用和泄露本邮件及附件的任何内容,以确保您无须为此承担法律责任。谢谢您的合作!
******NOTICE******
This email and any files transmitted with it may contain legally PRIVILEGED and/or CONFIDENTIAL INFORMATION, and are intended solely for the personal use of the recipient(s) named above. Without prior consent, you should not disseminate this communication to any irrelevant party. If you have received this communication in error, please immediately notify this sender and permanently delete the original & duplicate copy, and any printout thereof. Any dissemination, distribution or copying of this communication is STRICTLY PROHIBITED. Thank you!
More information about the Cpp
mailing list