kokke / tiny-regex-c

Small portable regex in C
The Unlicense
1.23k stars 175 forks source link

re_matchp succeeds only for the first string compared to a pattern #71

Open MiloDC opened 3 years ago

MiloDC commented 3 years ago

re_t myRe = re_compile("^[^=]+=[^=]+$"); int matchLen; re_matchp(myRe, "operationName=PublishEditMessageClients", &matchLen); (= > -1) re_matchp(myRe, "operationName=DeleteMessageClients", &matchLen); (= < 0) re_matchp(myRe, "operationName=PublishEditMessageClients", &matchLen); (= > -1) re_matchp(myRe, "operationName=PublishDirectMessageClients", &matchLen); (= < 0)

As you can see, only the first string matched against the pattern yields a successful match. Any other string thereafter yields failure. Why is this?

Amiralgaby commented 3 years ago

in re.c there is this written

/*
 *   '[abc]'    Character class, match if one of {'a', 'b', 'c'}
 *   '[^abc]'   Inverted class, match if NOT one of {'a', 'b', 'c'} -- NOTE: feature is currently broken!
*/

I see you use inverted class, but i don't realized test if you are right