Skip to content

Setting optional group uses wrong offset #14

@tek

Description

@tek

This appears to be similar to #7, but since it happens in 1.1.0.0, I thought you might have overlooked something.

ghci> "aaxxc" & [regex|aax(b)?x(c)|] . group 0 .~ "B"
"Baaxxc"
ghci> "aaxxc" & [regex|(aa)x(b)?x(c)|] . group 1 .~ "B"
"aaBxxc"

When the optional group is the last one, nothing is changed:

ghci> "aaxxc" & [regex|(aa)x(b)?xc|] . group 1 .~ "B"
"aaxxc"

Like in the other issue, making the optional group non-capturing and wrapping it in a new group works around the issue:

ghci> "aaxxc" & [regex|(aa)x((?:b)?)xc|] . group 1 .~ "B"
"aaxBxc"

No worries if this is too awkward to implement reliably, the workaround is tolerable 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions