- Notifications
You must be signed in to change notification settings - Fork13
Numerical quantifies don't work when SRL contains a non-capturing group #11
Description
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 thesimple 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 fromexactly 5 times totwice, 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