Logmanager documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Text trim whitespaces

This block is used to remove spaces around the 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 the source string. This argument is required. The output of the block is a string value with removed spaces.

In case the supplied string variable is not actually string, it returns None.

Block XML representation

XML representation of the 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>

Example of visual representation

Block "Trim spaces from"

Block “Trim spaces from”

Example of block usage

Example of "Trim spaces from" block

Example of “Trim spaces from” block

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.

Processing result

Results of "Trim spaces from" block

Results of “Trim spaces from” block