Regex to delete double or more spaces

Hi all,

I’m trying to remove extra spaces in a string:

  • Trim leading and trailing spaces :white_check_mark: (using trim())

  • Also collapse double/multiple spaces between words into a single space :cross_mark: (this part fails)

What I tried (didn’t work):

{{trim(replace("test bron this test "; “/\s+/g, ’ '”; ))}}

Also tried many other patterns, one of them: ,\s? but unfortunately no succes..

Community to the rescue? :slight_smile:

Your code formatting is incorrect.

{{ trim(replace("test bron    this  test     "; "/\s+/g"; space)) }}
2 Likes