aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tests/regex.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/regex.cpp b/src/tests/regex.cpp
new file mode 100644
index 0000000..eb3aff6
--- /dev/null
+++ b/src/tests/regex.cpp
@@ -0,0 +1,31 @@
1#include <bu/regex.h>
2#include <stdio.h>
3
4int main( int argc, char *argv[] )
5{
6 if( argc < 3 )
7 {
8 printf("No... %s <regex> <string>\n\n", argv[0] );
9 return 0;
10 }
11
12 Bu::RegEx re( argv[1] );
13
14 printf("Regex: %s\n", argv[1] );
15 printf("Match: %s\n", argv[2] );
16
17 if( re.execute( argv[2] ) )
18 {
19 for( int j = 0; j < re.getNumSubStrings(); j++ )
20 {
21 printf("SubStr %d: %s\n", j, re.getSubString( j ).getStr() );
22 }
23 }
24 else
25 {
26 printf("Regex did not match.\n");
27 }
28
29 return 0;
30}
31