Expand my Community achievements bar.

Come join us for our Coffee Break next week on top takeaways from Adobe Summit!

Remove spaces in calculated strings

Avatar

Level 3
The REPLACE() function seems to behave normally. Until you try to replace a " "(space) with a ""(no space). It doesn't like the no space thing. How do I remove all the spaces from a string? I can put in about any other character but not "no space". Byron Nash INSP, LLC.
7 Replies

Avatar

Level 10
Huh: confirmed, Byron. I've never noticed that. I'd suggest you report it as a bug, but suspect there might be a technical/security reason preventing it (although I can't think of one, myself). Regards, Doug Doug Den Hoed - AtAppStore

Avatar

Level 3
Thanks, I submitted a ticket. Byron Nash INSP, LLC.

Avatar

Level 3
It appears to be a limitation of the syntax according to support. Does anyone have any workarounds for this sort of thing? Byron Nash INSP, LLC.

Avatar

Level 4

@ByronNa 

Still appears to be happening. I can't think of a workaround. Did you find one??

 

Hi @ByronNa and @RobertDy,

 

Thanks for re-raising this challenge. I decided to solve it.

 

Unfortunately, the bug preventing the REPLACE function from substituting a " " with "" has not yet been fixed:

 

REPLACE({name}," ","")

 

However...

 

After a transcendental meander through my Save Until Needed Vault, I am pleased to share the following workaround, as shown below:

 

Doug_Den_Hoed__AtAppStore_0-1704329757670.png

 

Here is the textmode for each column:

 

displayname=Replace Spaces With ~
textmode=true
valueexpression=REPLACE({name},' ','~')
valueformat=HTML
displayname=Replace Spaces with New Line
textmode=true
valueexpression=REPLACE({name}," ","\\u000A")
valueformat=HTML

and last but not least, the One You're After:

displayname=Replace Spaces with Null Character
textmode=true
valueexpression=REPLACE({name}," ","\\u0000")
valueformat=HTML

 

Note, though, that (as I mentioned in this related post)...because these formulas leverage Unicode control characters there is a GOTCHA: "...remember to always re-supply the extra leading \ symbols that are sacrificed whenever such calculations are edited via the front end (vs pushing such calcs in via the API)."

 

That aside: one more down, zillions to go.

 

Have fun.

 

Regards,

Doug

Thanks for looking into this @Doug_Den_Hoed__AtAppStore 

So, when I tried this as a calculated field on a custom form, this is how I had to implement it to work:

REPLACE("test123","123","\u0000")   =>  "test"
(Only a single \ symbol)

 

Really useful to have these two codes. Thank you.

 

Hopefully Workfront will resolve this bug.... (I won't be holding my breath though)

 

My pleasure @RobertDy,

 

That is encouraging that the custom form builder you used is "smart enough" to not need the double \\ prefix that the textmode editor requires (since the latter "swallows" the leading \ upon save): perhaps the dev team can use the former to expedite fixing the latter (cc @jon_chen to relay accordingly, please).

 

Regards,

Doug