summaryrefslogtreecommitdiff
path: root/src/tests/regex.cpp
blob: 0a33a93f292028ac1b6a7c261afae512b794baee (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
32
33
34
35
36
37
38
/*
 * Copyright (C) 2007-2010 Xagasoft, All rights reserved.
 *
 * This file is part of the libbu++ library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#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;
}