View Full Version : Question about a doubt in Regular Expression – RWCRegexp class

01-29-2009, 01:38 AM
#include all necess... headers

RWCString aString("AA098765");

RWCRegexp reg("^[A-Z]{2}[0-9]{6}$");

cout << "Rx = " << aString(reg) << endl;
Rx =

I am new to RWCRegexp class.
I run the above program, but I didn’t get the output. Please explain why I am not getting the output. Thank in advance.

Is the RegEX is correct, i need to accept only the string with the given regexp format. Please help me ASAP

01-30-2009, 03:36 AM
The class RWCRegex does not have the { } parameter defined in the class. You will need to use the RWTRegex<T> class to use the {} functionality. Here is a sample of the code you have using the RWTRegex<T> class:

#include <iostream>
#include <rw/cstring.h>
#include <rw/tools/regex.h>

int main()
RWCString a("AA098765");
RWTRegex<char> re("^[A-Z]{2}[0-9]{6}$");
RWTRegexResult<char> result;
result = re.search(a);
std::cout << "result: " << result.subString(a) << std::endl;

return 0;

This is the output as expected:
result: AA098765