tags:

views:

70

answers:

2

I have the following code.

sregex rex = sregex::compile( "(\\w+) (\\w+)!" );

How I can get "(\w+) (\w+)!" out from rex?

A: 

The str() member function.

Edit: Oops -- sorry, I didn't pay attention to the fact that you were using sregex instead of the normal regex. I don't believe sregex provides a way to retrieve the original string.

Jerry Coffin
A: 

Looking at the documentation for basic_regex<> (sregex is just a typedef for basic_regex), I don't see any function that looks like it can retrieve the original textual representation of the regular expression.

If you really need that, you are going to have to create your own class that holds both a sregex and a std::string.

R Samuel Klatchko