diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-01-07 00:24:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-01-07 00:24:08 +0000 |
commit | 17c92cf5b2b0dfdfdbbdb5c41354634ca98ae1b4 (patch) | |
tree | 7109629e83314cf73be9233b6a3a3c70031eff94 /src/tests/regex.cpp | |
parent | 2dd476ff6dc904174446f269eeb97ccf9ed8c379 (diff) | |
download | libbu++-17c92cf5b2b0dfdfdbbdb5c41354634ca98ae1b4.tar.gz libbu++-17c92cf5b2b0dfdfdbbdb5c41354634ca98ae1b4.tar.bz2 libbu++-17c92cf5b2b0dfdfdbbdb5c41354634ca98ae1b4.tar.xz libbu++-17c92cf5b2b0dfdfdbbdb5c41354634ca98ae1b4.zip |
Added a new class, RegEx, it does extended regular expressions for now, more to
come.
Diffstat (limited to '')
-rw-r--r-- | src/tests/regex.cpp | 31 |
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 | |||
4 | int 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 | |||