Text trim whitespaces
Block is used for removing spaces around source string.
Removing modes:
- both sides: remove spaces from both sides of the string,
- left side: remove spaces from left side of the string,
- right side: remove spaces from right side of the string.
Right part defines source string and argument is required. Output of the block is a string value with removed spaces.
In case supplied string variable is not actually string returns None.
XML representation of text_trim block
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="text_trim">
<field name="MODE">BOTH</field>
<value name="TEXT">
<block type="text">
<field name="TEXT">input_string</field>
</block>
</value>
</block>
<block type="text_trim">
<field name="MODE">LEFT</field>
<value name="TEXT">
<block type="variables_get">
<field name="VAR">input_var</field>
</block>
</value>
</block>
<block type="text_trim">
<field name="MODE">RIGHT</field>
<value name="TEXT">
<block type="variables_get">
<field name="VAR">input_var</field>
</block>
</value>
</block>
</xml>
Block is used twice in the example:
- “Set user_trim to … both sides” row: remove spaces from both sides of string " username “. Output is value “username” without spaces.
- “Set user_trim to … right side” row: remove spaces from right side of string " username “. Output is value " username” without space in the right side of string.