Saving compiled PCRE regular expressions in C / C ++

Is there an efficient way to store compiled regular expressions (compiled via regcomp (), PCRE) in a binary, so that later I can just read from the file and call regexec ()?

Or is it just a matter of dropping the compiled regex_t structures to a file and reading them if necessary?

+4
source share
1 answer

Unless you have a supercomplex regex , I hardly see the benefits of serializing a compiled regex, the compilation time should not be that long. If you are not in a super-tight embed system?

In any case, dumping structures may be the solution, at least you can try ...
[EDIT] I just looked at the source that I have (6.7), and as I was afraid it wasn’t so simple, the structure starts with void * ... You cannot serialize pointers, you need to recount them.

+4
source

Source: https://habr.com/ru/post/1277661/


All Articles