Skip to content
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 search for substring with grammar? #237

Open
nurdann opened this issue Aug 22, 2023 · 0 comments
Open

How to search for substring with grammar? #237

nurdann opened this issue Aug 22, 2023 · 0 comments

Comments

@nurdann
Copy link

nurdann commented Aug 22, 2023

Can I use grammar to search for its occurrence in a text instead of matching the entire string?

e.g with following grammar

log = "(" userid "&" lat ")"
userid = ~"user_?id=[0-9a-zA-Z]+"
lat = "lat" delimeter float
delimeter = "=" / ":"

float = digits ("." digits)?
digits = ~"[0-9]+"

I can match

(user_id=1000&lat=23.3)

Can I search for substring? e.g.

prefix (user_id=1000&lat=23.3)

And more complex: what if I want to search for key-value pairs, e.g. user_id, lat inside paranthesis? so I'd want to match the following strings as well,

(... user_id=1000 .... lat=23.3 ...)

Would unwanted characters be part of the grammar as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant