aboutsummaryrefslogtreecommitdiff
path: root/regexptest.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-21 18:03:28 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-21 18:03:28 +0000
commit51e21a316be6e052251b3dfc7d671061ebd67cee (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /regexptest.cpp
parentad6f4dfcc671d3f8d458c42b0992956f2a2cf979 (diff)
downloadbuild-51e21a316be6e052251b3dfc7d671061ebd67cee.tar.gz
build-51e21a316be6e052251b3dfc7d671061ebd67cee.tar.bz2
build-51e21a316be6e052251b3dfc7d671061ebd67cee.tar.xz
build-51e21a316be6e052251b3dfc7d671061ebd67cee.zip
Removed the old trunk contents. About to load up m3
Diffstat (limited to 'regexptest.cpp')
-rw-r--r--regexptest.cpp47
1 files changed, 0 insertions, 47 deletions
diff --git a/regexptest.cpp b/regexptest.cpp
deleted file mode 100644
index 01597be..0000000
--- a/regexptest.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
1#include <stdio.h>
2#include <regex.h>
3#include <string>
4
5int test( const char *str, const char *sRegExp )
6{
7 printf("Compiling: %s\n", sRegExp );
8 regex_t r;
9 if( regcomp( &r, sRegExp, REG_EXTENDED|REG_NEWLINE ) )
10 {
11 printf("Error compiling regular expression.\n");
12 return 0;
13 }
14
15 printf("Compiled, %d sub expressions.\n", r.re_nsub );
16
17 int nMatch = r.re_nsub+1;
18 regmatch_t *match = new regmatch_t[nMatch];
19 if( regexec( &r, str, nMatch, match, 0 ) )
20 {
21 printf("Regular expression did not match.\n");
22 return 0;
23 }
24
25 printf("Match!\nSubstrings:\n");
26 for( int j = 0; j < nMatch; j++ )
27 {
28 printf(" %d: (%d-%d) %s\n",
29 j,
30 match[j].rm_so, match[j].rm_eo,
31 std::string(str+match[j].rm_so, match[j].rm_eo-match[j].rm_so ).c_str()
32 );
33 }
34
35 delete[] match;
36 regfree( &r );
37}
38
39int main( int argc, char *argv[] )
40{
41 printf("Regular expression test:\n\n");
42
43 test( argv[1], argv[2] );
44
45 return 0;
46}
47