-
Notifications
You must be signed in to change notification settings - Fork 526
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
Improving pattern for regex capture and matches predicates #4
Comments
I ran into this today, and was just coming to file a docs issue before seeing this already open. Here is what I hit:
It wasn't intuitive to me that I needed to escape my backslashes, especially since there aren't any examples of this in the docs (I looked at your tests to figure out what the problem was). Could you support At the very least, more significant examples in the docs would help a lot. |
Thanks for your suggestion. It really improves the readability of the Hurl file. |
Yes, big fan of @humphd suggestion for regex syntax, feels natural. |
Regex Literals /.../ should probably not include any Hurl template. We could maybe still use a string value for the match only if we need a template.
|
Currently, regex patterns are used in :
Pattern in Hurl grammar use
quoted-string
: the problem is that backslash inquoted-string
should be escaped. So to use special character in pattern (like\d
,\s
), backslash should be escaped, degrading the readability of the pattern:In Rust, Python, Kotlin, raw strings are used to improve the regex readability. In Rust, for instance:
In the Hurl grammar, we already have raw string (```something\ntutu``` is literally the string "something\ntutu" without a newline between something and tutu). We could reuse this syntax when using regex query or matches predicates:
Before:
After:
We could also introduce another syntax, like Python raw string and Rust raw string and keep ``` for body raw string:
raw-string like r"abcd" could be used anywhere a quoted-string is used (not limited to regex capture and matches predicate)
The text was updated successfully, but these errors were encountered: