Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <regex.h>
- #define NUM_MATCHES 2
- char data[] = "aaaaaaaaaaaaasdffffffffffffffsdfsdfdsfsdfsdfsdfffffffffff 11111 sdfsdfsdfsf aasdfa xxx zzz0bbb-3345sdfsfdsxxxxxxxxxxxxxxxxxxxxxx";
- int main(void)
- {
- regex_t preg;
- regmatch_t pmatch[NUM_MATCHES];
- regcomp( &preg, "b+-([0-9]+)", REG_EXTENDED );
- int i;
- for( i = 0; i < 1000000; i++ )
- {
- regexec (&preg, data, NUM_MATCHES, pmatch, 0);
- }
- printf( "%d %d\n", pmatch[ 1 ].rm_so, pmatch[ 1 ].rm_eo );
- regfree (&preg);
- return 0;
- }
- ----------------------
- gcc -O3 -c parse.c -o parse.o
- gcc -O3 -o parse parse.o
- 95 99
- real 0m3.068s
- user 0m3.063s
- sys 0m0.000s
Advertisement
Add Comment
Please, Sign In to add comment