|
Home > Archive > Unix Programming > December 2007 > Regarding regular expressions in Solaris
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Regarding regular expressions in Solaris
|
|
|
| Hi,
Am writing one C program for one of my module and facing one problem
with the regular expression functions provided by the library libgen.h
in solaris.
In this library we are having two functions to deal with
the regular expressions
char *regcmp(const char *string1, /* char *string2 */ ,
int /*(char*)0*/); ------this function is to compile the regular
expression.In case of failure it will return NULL.
char *regex(const char *re, const char *subject, /*
char *ret0 */ ...);---------This function is used to execute the
compiled expression against the subject string.
Problem
Compiled and executed the following regular expression
using the above two function like below.
char *name = regcmp("[A-Z]*",(char*)0);
const char *newcursor = regex(name,"ps");
In the above case written the regular expression only to check
whether the given value is capitals or not. To check this one I
submitted the value "ps" in lower case. Still the regular expression
is executing succefully wit out failure.In the above case it shold
have to fail but still it is successful. The regex function is not
returning NULL in this case.
If anybody knows abot this please let me know.
Regards
Sunil.
| |
| fjblurt@yahoo.com 2007-12-13, 7:33 am |
| On Dec 12, 11:48 pm, sunil <sunil....@gmail.com> wrote:
[...]
> Compiled and executed the following regular expression
> using the above two function like below.
>
> char *name = regcmp("[A-Z]*",(char*)0);
> const char *newcursor = regex(name,"ps");
>
> In the above case written the regular expression only to check
> whether the given value is capitals or not. To check this one I
> submitted the value "ps" in lower case. Still the regular expression
> is executing succefully wit out failure.In the above case it shold
> have to fail but still it is successful. The regex function is not
> returning NULL in this case.
This is correct. The regex you give matches an occurrence of zero or
more capital letters. The string "ps" does contain a match of this,
namely, zero capital letters.
You might have meant something like "^[A-Z]*$".
|
|
|
|
|