Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Formula for removing whitespace

RajatRehria
8 - Asteroid

Hi all, is there any formula to remove the extra whitespaces anywhere from the line texts (except cleansing tool), not Trim formula as it only removes extra spaces from left and right but i want to remove extra spaces anywhere places in the line of texts using only the formula. Thanks.

4 REPLIES 4
DataNath
17 - Castor
17 - Castor

Hey @RajatRehria, you can just use the replace() expression with a space as your target:

 

Replace([Field],' ','')
Christina_H
14 - Magnetar

If you have longer strings of spaces, you can use RegEx to remove them.  Trim(REGEX_Replace([Text],"\s+"," "))

 

image.png

RajatRehria
8 - Asteroid

Pls show the Regex formula as well, when using the !Startswith(Trim(REGEX_Replace([Row-1:Data],"\s+"," ")) then getting formula error

Christina_H
14 - Magnetar

@RajatRehria RegEx formula is included in the original post, it is:

Trim(REGEX_Replace([Text],"\s+"," "))

 

You've included !Startswith in your formula, which isn't necessary for removing the spaces and you haven't included enough parameters: StartsWith(String, Target)

Labels
Top Solution Authors