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

regex support? #409

Open
ghostsquad opened this issue May 11, 2020 · 3 comments
Open

regex support? #409

ghostsquad opened this issue May 11, 2020 · 3 comments

Comments

@ghostsquad
Copy link
Contributor

Is there a way to perform regex search/replace or just search?

If not, would this be desired functionality?

@sbarzowski
Copy link
Collaborator

It's not included in the current version, but there are plans to add regexp support and there is some progress towards it. The idea is to support a subset re2 regexes without \C (like Go's regexps).

Unfortunately it will certainly introduce (small) differences between regexps supported by the implementations. This occupies a similar place as YAML – it is very useful, but the spec is not as precise as we would like.

FYI I have also played with an alternative – parser combinators, which are in some ways superior to regexps: https://github.com/sbarzowski/jsonnet-parser-combinators. Here is an example of parsing (and evaluating) arithmetic expressions using that library: https://github.com/sbarzowski/jsonnet-parser-combinators/blob/master/examples/arithmetic.libsonnet.

@sh0rez
Copy link
Contributor

sh0rez commented May 12, 2020

In Tanka we inherited the ksonnet / kubecfg native funcs, which directly expose Go standard library utilities:

Not having too much experience with them, but some people seem to use them and I did not hear any complaints so far

@ghost
Copy link

ghost commented Jun 8, 2023

I would suggest adding regex support (search, replace) and specify it as using the re2 spec. You won't find a better specified and more cross-language spec or regular expressions than re2 I think.

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

No branches or pull requests

3 participants