Re: Cocoa application and regular expression
Re: Cocoa application and regular expression
- Subject: Re: Cocoa application and regular expression
- From: Frederick Cheung <email@hidden>
- Date: Thu, 23 Sep 2004 14:09:10 +0200
On 23 Sep 2004, at 13:08, Emmanuel Verlynde wrote:
Where can i find regex tutorial???
I try to use regular expression but always return false...
#include <regex.h>
...
-(bool)checkStr: (const char *)str
{
char * pattern;
regex_t rg;
bool ret;
...
pattern = "^\\d{5}$";
...
regcomp(&rg, pattern);
Over here regcomp takes an additional flag parameter, of which a
possible value is REG_EXTENDED. By default you get basic regular
expressions (see man re_format) but basically it means that a bunch of
characters don't have the special meaning you expect (eg { and } are
ordinary characters, \{ and \} are the ones used to indicate
repetiion). Also \d is a perl thingy, with the built in regex library
you want [[:digit:]] instead.
Fred
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden