Skip to content

Returning an array of captures with IDs. #847

@zherczeg

Description

@zherczeg

I saw an interesting request which made me thinking. While PCRE is perfectly capable of matching complex patterns, it could only return with a fixed set of captures. For example, it can parse a table with columns, but it cannot return with the column list, since the number of columns is not fixed.

The feature would look like this: (*push:<ID>PATTERN). The character range with its ID is pushed onto a stack. When the engine backtracks, the item is popped as well.

Since allocating new items may fail, this construct may break matching. By default, there is no stack, so using this construct always aborts the match. The user application must allocate the stack (with its allocation limit), and add it to match data. The cost is an extra pointer in match data for those applications, which does not use this feature.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions