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

Support a replace function #52

Conversation

phroggyy
Copy link
Contributor

This adds support for a new replace function that can be used in CEL expressions. It uses the RE2 syntax just like the rest of CEL.

This can be useful for arbitrarily transforming and extracting text. When using escaping characters to have them parsed as regex literals (e.g \. to represent a period), make sure to escape your backslash.

This adds support for a new `replace` function that can be used in
CEL expressions. It uses the RE2 syntax just like the rest of CEL.
Copy link
Contributor

@paprikati paprikati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is lovely. Can we add it to the docs, upversion, and ship?

Copy link
Member

@lawrencejones lawrencejones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to cut a new release by modifying the VERSION file and pushing a commit with that change to master once this is merged.

src = "replace(value, r'^https://([0-9A-Za-z_\\-]+)\\.example\\.com.*$', '$1')"
})

When("The input is a matching string", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally lowercased

@phroggyy phroggyy merged commit 35008ac into master Jul 15, 2023
1 check passed
@phroggyy phroggyy deleted the leosjoberg/eng-10401-support-regex-or-env-var-substitution-in-catalog-importer branch July 15, 2023 11:20
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

Successfully merging this pull request may close these issues.

3 participants