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

Text index of substring

“In text find” block is used to get position of searched character or string. Left part defines the source string and this argument is required.

Middle part is selection box:

  • first: returns position of first occurrence of the searched character or string,
  • last: returns position of last occurrence of the searched character or string.

Right part defines searched character or string and argument is required. Output of the block is integer value of the string position. If searched string is not found, output value of the block is “-1”.

In case string search can’t be performed for example input value is not string block returns None.

Block XML representation

XML representation of text_index_of block:

<xml xmlns="http://www.w3.org/1999/xhtml">
  <block type="text_index_of">
    <field name="END">FIRST</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">text</field>
      </block>
    </value>
    <value name="FIND">
      <block type="text">
        <field name="TEXT">sub_str</field>
      </block>
    </value>
  </block>
</xml>

Example of visual representation

Block "In text find"

Block “In text find”

Example of block usage

Example of "In text find" block

Example of “In text find” block

User name is acquired from the input message in example.

Block is used on the “set user_position” row in the example:

  • “In text find” block reads value of message raw and finds last occurrence of “user:” string.
  • Result is value “72”.
  • This value is used in next “In text get substring” block, where string “user: administrator” is loaded.
  • String is saved into the “user_part” variable.
  • “user_part” variable is used in the next “In text get substring” block.
  • Output is value “administrator”.

Input data

Login permitted from 192.168.10.1/1234 to inside:192.168.1.1/https for user: administrator

Processing result

Results of "In text find" block

Results of “In text find” block