Match strings that start and end with the same character #894
Unanswered
matias-santurio
asked this question in
Q&A
Replies: 1 comment
-
You can avoid consuming the whole string using predicates:
But I'm not sure that this method is very efficient (I think that for every character the parser checks if the next is EOI). Using that I was able to write the grammar you described, see this grammar on the playground. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to write a grammar rule that matches strings that start and end with the same character, so a rule that matches:
but not
My first thought was to write something like
but of course, matching is greedy so
ANY*
consumes the whole string, is there a way to get around this?Beta Was this translation helpful? Give feedback.
All reactions