-
Notifications
You must be signed in to change notification settings - Fork 3
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
Consider supporting regular expressions #15
Comments
Tu use regular expressions in a
ExampleConsider the following JSON document {
"assets": [
{ "name": "first-name" },
{ "name": "last-name" },
{ "name": "other" }
]
} To select all ```
[ { "name": "first-name"}, {"name": "last-name"} ]
|
To support regular expressions to replace substring, we would need a new function:
For instance, using the same example as the previous comment, the following expression:
would evaluate to:
Maybe something like:
|
Finally, a function could return the named or numbered captures from a regex.
Example: The simplest usage could look like:
Which evaluates to a JSON object if the match is successful: { "0": "hello" } Adding capturing groups would be supported like so:
Would return: {
"0": "hello, world!",
"1": "hello"
} Likewise, this expression:
Would evaluate to: {
"0": "hello, world!",
"first": "hello",
"second": "world"
} This is currently not very useful, but in light of the probably upcoming function let, we could have expressions like so:
|
There seems to be some demand for supporting regular expressions.
This presents some challenges as there are many different dialects of regexp, although there is an effort around
specifying an interoperable regex format.
Also, regular expressions uses cases fall into three main categories:
filter-expressions
. It either matches, or it does not.So a JEP would need to come up with intuitive syntax for those use cases that would be relevant.
The interoperable regex format proposal referred to above only supports the first scenario. So maybe that’s the only scenario that requires extending the JMESPath syntax.
The last two scenarios may be supported using dedicated functions.
The text was updated successfully, but these errors were encountered: