regex library in c3 language
This is a 1:1 translation of C Regex ( https://github.com/ximtech/Regex ) for learning purpose.
demo:
import regex;
import std::io;
fn void main()
{
Regex regex;
regex::compile(®ex,"[Hh]ello [Ww]orld\\s*[!]?");
if(!regex.isPatternValid)
{
io::printf("Error: %s\n",regex.errorMessage);
return;
}
Matcher matcher=regex::match(®ex,"ahem.. 'hello world !' ..");
io::printf("Is found: %s\n", matcher.isFound ? "Yes" : "No");
io::printf("At index: %d\n", matcher.foundAtIndex);
io::printf("Length: %d\n", matcher.matchLength);
}