StringFind (FPScript)

21.09.2021

Searches for a substring and returns its position.

Syntax

StringFind(String, Substring [ , IgnoreCase = FALSE ])

 

The syntax of the StringFind function consists of the following parts:

Part

Description

String

String to be searched.

Permitted data structures are scalar value, data series und data matrix. Supported data types are string.

Substring

Substring for which to search.

Permitted data structures are scalar value. Supported data types are string.

IgnoreCase

A Boolean value that specifies whether to ignore the case when performing a search.

Permitted data structures are scalar value. Supported data types are Boolean value.

If this argument is omitted, it will be set to the default value FALSE.

Remarks

The data type of the result is always 32-bit integer.

The structure of the result corresponds to that of the argument String.

The result is the position of the substring found. If the substring is found more than once, only the first position is returned. The positions are counted starting from zero. If nothing was found, -1 is returned.

If the String argument is a data series or data matrix, the calculation is performed on a per-element basis and the result is either a data series or a data matrix.

If an argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Available in

FlexPro Basic, Professional, Developer Suite

Examples

StringFind("Using StringFind", "StringFind")

Results in 15.

StringFind("Using StringFind", "stringfind", TRUE)

Results in 15. Finds the substring despite the difference in case.

StringFind({"M75_2016", "M633_2016", "M11850_2016"}, "_")

Results in the positions of the substring as a data series with 32-bit integral values {3, 4, 6}.

Dim names = {"M75_2016", "M633_2016", "M11850_2016"}
Dim pos = StringFind(names, "_")
return StringLeft(names, pos)
 

Results in the data series {"M75", "M633", "M11850"}.

See Also

SearchStrings Function

SearchValue Function

StringReverseFind Function

StringReplace Function

StringLeft Function

StringRight Function

StringMid Function

StringConcat Function

Share article or send as email:

You might be interested in these articles