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

Improve regex replacement. #34146

Closed
h0cheung opened this issue Jul 18, 2024 · 5 comments
Closed

Improve regex replacement. #34146

h0cheung opened this issue Jul 18, 2024 · 5 comments

Comments

@h0cheung
Copy link
Contributor

h0cheung commented Jul 18, 2024

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

The standard regexp in Go is sometimes powerless, which make us hard to do some replacement.

For example, I want to replaces pure number path segment in a http url. I tried to use some expression: /\d+(/|$) to /?$1.

However, if there are continuous segments, they won't be replaced at once: /12/34/56/78 -> /?/34/?/78. As positive lookahead is not supported, the only workaround I find this to replace by this expression again, but it will cause 2x cpu usage.

(/\d+){1,}(/$) can match perfectly, but I can't find a way to replace each match of (/\d+) to /?.

Describe the solution you'd like

  1. Consider supporting some powerful regex engine, such as https://github.com/dlclark/regexp2. Let users choose which engine to use according to their needs.
  2. Enhance the functions to replacing each match of some expression ends with {x,}

Describe alternatives you've considered

No response

Additional context

No response

@h0cheung h0cheung added enhancement New feature or request needs triage New item requiring triage labels Jul 18, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@evan-bradley evan-bradley removed the needs triage New item requiring triage label Jul 18, 2024
@evan-bradley
Copy link
Contributor

I think it would likely make sense to offer a more powerful alternative regex engine for cases like this where the built-in Go engine isn't sufficient. We could probably add an engine or lang optional parameter to our functions to allow selecting what is used.

@TylerHelmuth
Copy link
Member

Related to #32167

Copy link
Contributor

github-actions bot commented Oct 8, 2024

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Oct 8, 2024
Copy link
Contributor

github-actions bot commented Dec 7, 2024

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2024
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