Search/Split String Function

Owning Palette: Additional String VIs and Functions

Requires: Base Development System

Divides a single string into two substrings.

You can divide the string at a certain character or substring. Search/Split String searches string for the string or character in search string/char. The function splits the string and returns the resulting two strings in substring before match and match + rest of string.

Details  

 Add to the block diagram  Find on the palette
string is the input string the function searches or splits.
search string/char is the string or character to search for in string. If you do not wire this input or it contains an empty string, the function splits string at offset. You must wire either search char or offset.
offset specifies number of characters into string at which the function starts searching for a match. offset must be numeric. The offset of the first character in string is 0. If offset is unwired or less than 0, the function takes offset as 0.
substring before match returns the portion of string before search string/char or before offset if search string/char is unwired. If this function does not find the search string, substring before match returns the entire original string.
match + rest of string consists of search string/char and all subsequent characters in string. If this function does not find the search string, match + rest of string returns an empty string.
offset of match is the position of search string/char in string. If this function does not find the search string, offset of match returns -1.

Search/Split String Details

If you enable the Match Single Character option, this function uses only the first character in search string/char and searches string for this character. When finding the first match in string, this function splits string and returns the resulting two strings. To enable the Match Single Character option, right-click this function and select Match Single Character from the shortcut menu.

For example, when you specify Test string for string and str for search string/char, this function returns different resulting strings depending on whether you enable the Match Single Character option. The following table shows the resulting strings.

Match Single Character Disabled Match Single Character Enabled
substring before match Test Te
match + rest of string string st string