Regular expressions in C

I am curious if anyone knows a good way to execute regex in C? The only way I can think of is through Flex. Is this the only way or is there a better way?

Thanks!

+5
source share
7 answers

Uh ... The best way is

#include <regex.h>

This is the standard POSIX standard regexp API .

For systems other than POSIX, using your own alternative is one alternative; the basic regular expression mechanism is not so difficult to implement. I am sure that there are ready-made solutions too, I did not do this.

Think about it, I think glib has one.

+13

, :

regex library, TCL PostgreSQL. , NFA/DFA.

Regexes, (, a * a?), NFA. NFA DFA , O ( 2 × ()) . , , "" , .

"NFA" (. Ross Cox Thompson NFA ). - O (input.length * pattern.length), - - backrefs capture, , .

, NFA , , . (. TCL regex-dna).

+11

, Parsing (PEG). PEG , . , , regexp.

PEG , , C.

PEG, , LPeg. , , . PEG, , PEG .

Lua C LPEG , , Lua .

+1

, ? , , regex.h.

Yes, this is not a posix regex, it is wonderful that they have everything, so I wondered why they are not in C? Well, I found the answer, and I enjoyed it, they are, and heres how to use them

0
source

All Articles