Searching for and Replacing Text in a String

Complete the following steps to search for and replace text in a string.

  1. Add the Search and Replace String function to the block diagram.

     Add  Find
  2. Wire the string you want to search to the input string input of the Search and Replace String function.
  3. Wire the string you want to search for to the search string input.
  4. Wire the replacement string to the replace string input.
  5. To replace all occurrences of the text, set the replace all? input of the Search and Replace String function to TRUE. To replace the first occurrence, set replace all? to FALSE.
  6. Wire the result string output of the Search and Replace String function to a string indicator or VI or function that accepts a string as an input.
  7. Wire all error in and error out terminals on the block diagram.
  8. Run the VI. The offset past replacement output of the Search and Replace String function indicates the point in the string where LabVIEW found the first match of the text in replace string.

You also can replace text at a specified point in the string and find and replace text in VIs.