Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex (^|\b) is not handled correctly, but (\b|^) is #78

Open
juliangilbey opened this issue Nov 30, 2020 · 0 comments
Open

Regex (^|\b) is not handled correctly, but (\b|^) is #78

juliangilbey opened this issue Nov 30, 2020 · 0 comments

Comments

@juliangilbey
Copy link

The following small example shows that this regex is not handled correctly.

#include <stdio.h>
#include <tre/tre.h>

int main() {
  regex_t preg;
  int ret;

  tre_regcomp(&preg, "\\ba", REG_EXTENDED);
  ret = tre_regexec(&preg, "this is a word", 0, NULL, 0);
  printf("return value for \\ba is %d\n", ret);

  tre_regcomp(&preg, "^a", REG_EXTENDED);
  ret = tre_regexec(&preg, "this is a word", 0, NULL, 0);
  printf("return value for ^a is %d\n", ret);

  tre_regcomp(&preg, "(^|\\b)a", REG_EXTENDED);
  ret = tre_regexec(&preg, "this is a word", 0, NULL, 0);
  printf("return value for (^|\\b)a is %d\n", ret);

  tre_regcomp(&preg, "(\\b|^)a", REG_EXTENDED);
  ret = tre_regexec(&preg, "this is a word", 0, NULL, 0);
  printf("return value for (\\b|^)a is %d\n", ret);
}
euler:/tmp $ gcc -o testtre testtre.c -ltre
euler:/tmp $ ./testtre 
return value for \ba is 0
return value for ^a is 1
return value for (^|\b)a is 1
return value for (\b|^)a is 0

I'm using libtre version 0.8.0-6 on Debian, which is based on the 0.8.0 release.

Best wishes,

Julian

@juliangilbey juliangilbey changed the title Regex (^|\b) is not handled correctly, but (^|\b) is Regex (^|\b) is not handled correctly, but (\b|^) is Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant