All pastes #633318 Raw Edit

Unnamed

public text v1 · immutable
#633318 ·published 2007-07-25 16:34 UTC
rendered paste body
#include "trex.h"
#include <stdio.h>
#include <string.h>

#ifdef _UNICODE
#define trex_sprintf swprintf
#else
#define trex_sprintf sprintf
#endif



int main(int argc, char* argv[])
{
    if(argc < 2) { 
        printf("Usage: regex [regex] string");
        return 1;
    }

	const TRexChar *begin,*end;
	TRexChar sTemp[1024];
	const TRexChar *error = NULL;
	TRex *x = trex_compile(_TREXC(argv[1]),&error);

	if(x) { 
		trex_sprintf(sTemp,_TREXC(argv[2]));
		if(trex_search(x,sTemp,&begin,&end)) {
                  trex_printf(_TREXC("matches!\n"));
		}

		else {
			trex_printf(_TREXC("no match!\n"));
		}
		trex_free(x);
	}
	return 0;
}