This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C Library Regular Expression Problem


Hi folks

I don't know if this is the correct place for my bug report but
nevertheless I hope you can help me.

My problem regards pattern matching from the GNU C library when using
Extended Regular Expressions.

Why does the pattern "[0]{1}" match the string "00" (the quotes are just
for better readability!)??
Since I am expecting exactly one single 0 the two 0 from the test string
should in my opinion be rejected.

A simple test program:

----
#include "unistd.h"
#include "regex.h"

int main(void)
{
     int retval;
     regex_t reginfo;
     retval=regcomp(&reginfo,"[0]{1}",REG_EXTENDED | REG_NOSUB); // gives 0
     retval=regexec(&reginfo,"00",0,0,0); // gives also 0 (why?)
     return 0;
}

----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]