Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-07-26 18:44:48


John Maddock wrote:

> boost success = mystring >> myregex
> std::string s = mystring >> myregex/myformat

        I'd have thought that

        regex / string

should yield an iterator into the match groups container:

        for(g = regex / string; g++; g) {
                cout << "group = " << *g << endl;
        }

and hence

        if(regex/string)...

works because it yields a 'null' iterator if the comparison fails.
To substitute the groups into the format string:

        (regex/string) >> format

to reference group 3:

        (regex/string)[3]

Another possibility is just:

        m = regex/string;
        for (g = m.begin(); g++; m.end()) ..

ie. regex/string is a standard container supporting
random iterators.

-- 
John (Max) Skaller, mailto:skaller_at_[hidden] 
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
New generation programming language Felix  http://felix.sourceforge.net
Literate Programming tool Interscript     
http://Interscript.sourceforge.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk