Skip to content

[pkg/ottl] Add an ottl function that allows for the trimming of whitespaces or other specified symbols from an attribute #34100

Closed
@robbavey

Description

@robbavey

Component(s)

pkg/ottl

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

I would like a simple way to trim whitespace from an attribute

Describe the solution you'd like

I would like to be able to trim data from an existing attribute

For example

A field test exists in an event, which contains the string " this is a test ".

I would like to be able to transform this using an ottl function trim, that I would define as trim(attribute["test"]), which would trim this down to "this is a test".

By default, this would use the unicode definition of whitespace, but we would also allow an alternative version trim(attribute, symbols)
I would also like to be able to set my own definition of whitespace, by providing a string containing the symbols I would like to trim.

Describe alternatives you've considered

A user could do this using the existing replace_all_patterns function, but this is a common enough function that it may warrant a standalone function. Additionally, we can be unambiguous that we replace the Unicode definition of whitespace by default.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions