camunda / feel-scala

FEEL parser and interpreter written in Scala
https://camunda.github.io/feel-scala/
Apache License 2.0
123 stars 50 forks source link

Add Trim function for whitespace stripping #815

Closed jjettenCamunda closed 5 months ago

jjettenCamunda commented 7 months ago

Is your feature request related to a problem? Please describe. I have a process where user input is displayed to other users including an id for example "Do extra testing during integration", that id can then later be used by other users in commands like /markFinished Do extra testing during integration, this fails when either the initial id or the command invocation has extra whitespace that the user is not expecting.

Describe the solution you'd like I would like there to be a trim function similar to other languages like C# where whitespace before or after the string is removed but internal whitespace is preserved.

Related issues

saig0 commented 6 months ago

@jjettenCamunda thank you for reporting. :+1: This sounds like a useful function.

Proposal: add the following built-in function

// signature
trim(string): string

// examples
trim("hello world")    // --> "hello world"
trim("hello world  ")    // --> "hello world"
trim("  hello world")    // --> "hello world"
trim("  hello world  ")    // --> "hello world"
trim(" hello   world ")    // --> "hello   world"