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 Capture named groups should be null #19703

Closed
splitice opened this issue Jan 25, 2024 · 3 comments
Closed

Regex Capture named groups should be null #19703

splitice opened this issue Jan 25, 2024 · 3 comments
Labels
meta: awaiting author Pull requests that are awaiting their author. type: bug A code related bug.

Comments

@splitice
Copy link
Contributor

splitice commented Jan 25, 2024

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

Currently with parse_regex (and probably parse_regexes) an unmatched group matches as an empty string.

This is wasteful and creates problems should there be the need to match an empty capture vs not present capture (null)

Configuration

in VRL:
. = `parse_regex(.message, "^(abc: (?P<abc>[a-zA-Z]+))?")`

.abc will be "" on an empty or non matching .message

Version

0.26

Debug Output

-

Example Data

Additional Context

References

@splitice splitice added the type: bug A code related bug. label Jan 25, 2024
@jszwedko
Copy link
Member

Hi @splitice ,

This doesn't seem to be the case in the latest version of Vector, I see:


$ .message = "no match"
"no match"

$ . = parse_regex!(.message, r'^(abc: (?P<abc>[a-zA-Z]+))?')
{ "abc": null }

Can you try upgrading and seeing if it resolves the issue for you?

@jszwedko jszwedko added the meta: awaiting author Pull requests that are awaiting their author. label Jan 25, 2024
@splitice
Copy link
Contributor Author

@jszwedko You might be right, we are a bit behind. Thank you for your response, hopefully I didnt waste your time. I'll confirm with latest in the coming days.

I recall we had some performance regressions but I can't recall the specifics (probably metrics). I think thats why we never moved to 0.27.x (performance regression).

I'll certainly give a newer version a try and test again.

@jszwedko
Copy link
Member

👍 sounds good. I'll close this out but feel free to reopen if it doesn't resolve the issue for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta: awaiting author Pull requests that are awaiting their author. type: bug A code related bug.
Projects
None yet
Development

No branches or pull requests

2 participants