Example Code

Advanced Search String SubVI with Selectable Case Sensitivity

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

Coding that exemplifies how to add a selectable case sensitive functionality to the Search/Split String VI.

 

Description

This code searches the input string for the strings in the array "Strings to Find" and returns information on if (Any Found?), what (Output Strings), and where (Indeces Found) the strings were located. The search can even be customized to include or ignore case sensitivity.
The "Output Strings" array results in the same number of elements as "Strings to Find." It contains the found string at a given index if indeed the string was found, or the empty string if the string was not found.
The "Indices Found" array contains the index in "String to Search In" at which the corresponding element of "Strings to Find" was found, or -1 if the string was not found.
For example, if the string at index 2 in "Strings to Find" was found in the input string, then the element at index 2 of "Output Strings" will contain that same string. If that string was not found, then the element at index 2 of "Output Strings" will be the empty string.

 

Requirements

LabVIEW 2012 or compatible

 

Steps to Implement or Execute Code
1. Select if you would like to make a Case sensitive search
2. Insert the string to search in
3. Insert the strings to find
4. Check the Any Found? LED and both array indicators

 

Additional Information or References

Snippet.png

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.