Search code examples
c++regexboostregex-lookarounds

Isn't it possible to use 'Repeats' in the lookaheads for boost:regex?


I'm trying to extract some variables in my C++ code nested in blocks. For example, if I have

        DEL_TYPE_NONE,
            DEL_TYPE_DONE,
    DEL_TYPE_WAIT,

I'd like to match:

"DEL_TYPE_NONE"
"DEL_TYPE_DONE"
"DEL_TYPE_WAIT"

I made my pattern like this:

std::string pat("(?<=^[ \\t]?)[A-Z0-9_]+(?=,$)");

but I'm keep getting error message when compiler is trying to read my pattern. I don't understand but there is problem with ? mark after \\t? If I get rid of ? mark then it compiles and find only "DEL_TYPE_WAIT"

Why can't I use Repeats in the Lookahead? What can I try next?


Solution

  • I found the answer. No from this manual

    Lookbehind

    (?<=pattern) consumes zero characters, only if pattern could be matched against the characters preceding the current position (pattern must be of fixed length).