Comments (7)
I don't think regular expressions should be part of the core JMESPath syntax because different programming languages have different regular expression implementations, so it wouldn't be possible to guarantee that a regular expression run using JMESPath on Python would have the exact same results on PHP or Ruby or Lua or Go.
Instead I suggest writing your own custom function that makes Python regular expressions available to your code: https://github.com/jmespath/jmespath.py/blob/0.10.0/README.rst#custom-functions
I completely disagree with this assertion. Though many languages do indeed have different implementations, I estimate 99.999% of them use a PCRE library/implementation for regexes as PCRE has become the defacto standard for regular expressions. Moreover, if every language used the rationale to defer to implement regular expressions because other languages do it differently then no language would implement them. I find myself deferring to jq
90% of the time because jp
doesn't employ regular expressions.
from jmespath.jep.
jq
is an interesting comparison here. It actually bundles the full implementation of the regular expression library (a submodule that imports Oniguruma: https://github.com/stedolan/jq/tree/master/modules) that it uses in the C implementation of the tool - then different programming languages have bindings that depend on that shared implementation: https://github.com/stedolan/jq/wiki/FAQ#language-bindings
jmespath
works differently: rather than shipping a single C implementation that is shared by different languages, it encourages entirely fresh implementations in different languages with no shared code, but sharing instead a thorough set of compliance tests: https://jmespath.org/libraries.html
Tests are here: https://github.com/jmespath/jmespath.test/tree/master/tests
This approach could be used to add regular expression support, by spinning up a thorough compliance test and maybe defining a subset of regular expression syntax that must be supported in order for an implementation to pass the test.
It would be a lot of work though!
from jmespath.jep.
+1 vote for regex support!
from jmespath.jep.
Here's a really interesting proposal, for an interoperable subset of regular expressions: https://cabo.github.io/iregexp/draft-bormann-jsonpath-iregexp.html
It's still in early stages, but it looks like it's directly relevant to this conversation.
from jmespath.jep.
I'd be in huge support for adding regex support!
from jmespath.jep.
I don't think regular expressions should be part of the core JMESPath syntax because different programming languages have different regular expression implementations, so it wouldn't be possible to guarantee that a regular expression run using JMESPath on Python would have the exact same results on PHP or Ruby or Lua or Go.
Instead I suggest writing your own custom function that makes Python regular expressions available to your code: https://github.com/jmespath/jmespath.py/blob/0.10.0/README.rst#custom-functions
from jmespath.jep.
There's a useful comparison table of the differences between different language implementations here: https://web.archive.org/web/20130830063653/http://www.regular-expressions.info:80/refflavors.html
from jmespath.jep.
Related Issues (20)
- Function proposal - format()
- Spec extension namespace HOT 1
- Allow expression in index and slice expression HOT 1
- Out of curiosity, whatever happened to JEP-2 ? HOT 1
- Function proposal - entries() HOT 2
- [Proposal] add `error` function HOT 1
- [Initial feedback] Potential proposal for user-defined function HOT 2
- [Initial Feedback] New `like` and `match` keywords HOT 16
- Function proposal - split()
- [Initial Feedback] Recursive Tree Traversal HOT 3
- Allow string comparison
- Allow reference to external parameter
- Root node access
- Spec change - merge() function HOT 2
- Spec extension - string slice
- Function proposal - flatMapValues() HOT 2
- Function proposal - groupBy() HOT 4
- Function proposal - parseJson() HOT 1
- JEP Syntax Policy HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmespath.jep.