aboutsummaryrefslogtreecommitdiff
path: root/src/tests/regex.cpp
blob: eb3aff6c739bc740d1b4499cbb9103d35e4954de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bu/regex.h>
#include <stdio.h>

int main( int argc, char *argv[] )
{
	if( argc < 3 )
	{
		printf("No...  %s <regex> <string>\n\n", argv[0] );
		return 0;
	}

	Bu::RegEx re( argv[1] );

	printf("Regex:     %s\n", argv[1] );
	printf("Match:     %s\n", argv[2] );
	
	if( re.execute( argv[2] ) )
	{
		for( int j = 0; j < re.getNumSubStrings(); j++ )
		{
			printf("SubStr %d: %s\n", j, re.getSubString( j ).getStr() );
		}
	}
	else
	{
		printf("Regex did not match.\n");
	}

	return 0;
}