# RAPID funtion to remove white space

**URL:** <https://tech-community.robotics.abb.com/t/rapid-funtion-to-remove-white-space/9740>\
**Category:** RAPID Programming\
**Created:** [October 9, 2020, 2:04pm UTC](https://tech-community.robotics.abb.com/t/rapid-funtion-to-remove-white-space/9740 "2020-10-09T14:04:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottdf93](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@scottdf93](https://tech-community.robotics.abb.com/u/scottdf93)\
**Post date:** [October 9, 2020, 2:04pm UTC](https://tech-community.robotics.abb.com/t/rapid-funtion-to-remove-white-space/9740/1 "2020-10-09T14:04:51Z")

</div>

Is there a function that will remove all leading white space in a string?

Something equivalent to string.Trim() in c#

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [October 9, 2020, 2:23pm UTC](https://tech-community.robotics.abb.com/t/rapid-funtion-to-remove-white-space/9740/2 "2020-10-09T14:23:41Z")

</div>

You could write your own, or perhaps a routine. There is a predefined data, STR\_WHITE, for blank space. There are a lot of string functions available and I suppose you could use one or more to clear out any undesired white spaces.

---

<div class="post-metadata">

**Author:** ![Oliver\_L](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/oliver_l/32/98_2.png) [@Oliver\_L](https://tech-community.robotics.abb.com/u/Oliver_L)\
**Post date:** [October 12, 2020, 8:13am UTC](https://tech-community.robotics.abb.com/t/rapid-funtion-to-remove-white-space/9740/3 "2020-10-12T08:13:08Z")

</div>

FUNC string StrTrim(string sInput, string sTrim)  
VAR string sPart;  
VAR string sReturn;

FOR i FROM 1 TO StrLen(sInput) DO  
sPart:=StrPart(sInput,i,1);  
IF sPart\<\>sTrim sReturn:=sReturn+sPart;  
ENDFOR

RETURN sReturn;  
ENDFUNC

Needed and created it last week.  
Cheers
