08.12.2015, 15:17
Hey, everyone. Here's a implementation of Rob Pike's simple regex algorithm.
The matcher handles:
- but it's not hard to implement it, we can use a recursive descent parser or a elaborated Shunting-yard algorithm, and send the result to the matcher (next version, maybe
)
Return values:
0 - doesn't match
1 - found a match
Include: sregex.inc
Anyway, have fun.
The matcher handles:
c matches any literal character c* It doesn't handle parentheses (its purpose is to be simple not a complex regex engine)
. matches any single character
^ matches the beginning of the input string
$ matches the end of the input string
* matches zero or more occurrences of the previous character
- but it's not hard to implement it, we can use a recursive descent parser or a elaborated Shunting-yard algorithm, and send the result to the matcher (next version, maybe

Код:
sregex_match(regexp[], text[])
0 - doesn't match
1 - found a match
Include: sregex.inc
Anyway, have fun.