super-expressive icon indicating copy to clipboard operation
super-expressive copied to clipboard

Using endOfInput in assertNotAhead

Open forresto opened this issue 6 months ago • 0 comments

Seems related to #59

It should be possible to use endOfInput more than once in some contexts.

input

SuperExpressive()
    .allowMultipleMatches
    .lineByLine
    .group
        .range("a", "z")
        .assertNotAhead.subexpression(
            SuperExpressive().endOfInput
        ).end()
    .end()
    .endOfInput
    .toRegex()

expected

/(?:[a-z](?!$))$/gm
            ^

actual

/(?:[a-z](?!))$/gm
            ^

This is missing the $ that tells the match to not match end of the line.

If I do the input without subexpression,

SuperExpressive()
    .allowMultipleMatches
    .lineByLine
    .group
        .range("a", "z")
        .assertNotAhead.endOfInput.end()
    .end()
    .endOfInput
    .toRegex()

I get the error "This regex already has a defined end of input"

forresto avatar Aug 04 '24 10:08 forresto