Added gnu_regex.c
This commit is contained in:
parent
2372ccb95f
commit
87d082cba2
21
gnu_regex.c
Normal file
21
gnu_regex.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <regex.h>
|
||||
|
||||
int main() {
|
||||
regex_t regex;
|
||||
|
||||
regcomp(®ex, "pattern", 0);
|
||||
|
||||
char test_str[] = "This is a pattern example.";
|
||||
regmatch_t pmatch[1];
|
||||
|
||||
if (regexec(®ex, test_str, 1, pmatch, 0) == 0) {
|
||||
printf("Pattern found at position %d.\n", pmatch[0].rm_so);
|
||||
} else {
|
||||
printf("Pattern not found.\n");
|
||||
}
|
||||
|
||||
regfree(®ex);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user