Handling "Double Quotes" on string joining function

Allright @jarviscampbell

My suggestion would be to use one the most powerful tools available for strings, the Column Expression.
Your desired output is achievable through:

if (contains(column("carName")," ") == true) {
    column("color") + " \"" + column("carName") + "\""
} else {
    column("color") + " " + column("carName")
}

What it does:

  • It checks if the carName contains a space, resulting in true or false.
  • If true, create a string by concatenating: the color, a quote, the carName and another quote. Key here is that you have to escape the quote since it’s a special character. This is done with the backslash.
  • If false, concat only the color and carName with a space in between.

See WF:
Handling “Double Quotes” on string joining function.knwf (12.8 KB)

Hope this helps!

4 Likes