-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to implement regex quantifiers ? #336
Comments
Being worked on in #291 |
Any workarounds for limited length ? Grammar:
Input: Result:
|
Something like this seems to work: search
= pair*
pair
= $(n:number l:$letter+ &{ return l.length === n })
number
= n:$[0-9]+ { return parseInt(n, 10) }
letter
= [a-zA-Z] |
I will try. Thank you !! |
Now that 3.0.0 is out, you can do this: search
= (d:digit l:$letter|d| {return `${d}${l}`;})+
letter
= [a-zA-Z]
digit 'digit'
= n:[0-9]+ { return parseInt(n, 10) } |
I'm going to close this, but open it back up or comment here if 3.0.0 doesn't solve your problem. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regex knows quantifiers for example:
[0-9]{3}
for matching three numbers.
I need simple rules to parse this:
1A2BB3CCC
The result should be '1A', '2BB' and '3CCC'. The leading number is the length of the following letters.
I tried:
with input
1A2BB3CCC
. No success.Any idea/help ?
Thank you.
The text was updated successfully, but these errors were encountered: