Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Numerical quantifies don't work when SRL contains a non-capturing group #11

@AdamJacobson

Description

@AdamJacobson

I was trying to translate this regex for US zipcodes to SRL: ^[0-9]{5}(?:-[0-9]{4})?$

The SRL I came up with was this:
begin with, digit, exactly 5 times, ( literally '-', digit, exactly 4 times ), optional, must end
and I tested it on the simple regex site:

however, creating a new SRL object with this as input results in the following error:

Invalid parameter given for exactly at SyntaxException (<local_path>/node_modules/SRL/lib/Exceptions/Syntax.js:3:1) at buildQuery (<local_path>/node_modules/SRL/lib/Language/Helpers/buildQuery.js:49:23) at Interpreter.build (<local_path>/node_modules/SRL/lib/Language/Interpreter.js:32:24) at new Interpreter (<local_path>/node_modules/SRL/lib/Language/Interpreter.js:22:18) at new SRL (<local_path>/node_modules/SRL/lib/SRL.js:14:9)

But if I change the input from exactly 5 times to twice, everything works as expected:
begin with, digit, twice, ( literally '-', digit, exactly 4 times ), optional, must end

This issue does not occur if the SRL does not contain a non-capturing group.

Here's a shorter SRL text which causes the issue:
digit, exactly 5 times, (letter, twice) optional

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions