String_Find_First

Finds the first instance of the substring inside the string, and returns the position where that substring starts. The left-most position is 0, so a value of 0 would be returned if the string started with the substring. A value of -1 is returned if no instances of the substring are in the string.

Parameters

String to Parse

The string that gets searched.

Substring to Find

The instance of the substring to find in the parsed string.

Ignore Case

Indicates whether the case of the letters is taken into consideration.

Format

String_Find_First (String to Parse, Substring to Find, Ignore Case)

Example

Script( String_Find )

String( strOriginal )

String( strMessage )

String( strTitle )

String( strSearchFor )

Number( nFirstIndex )

Number( nLastIndex )

Activate( From_Menu )

strOriginal = Ask_String( "Enter a string to search", "String_Find", 1, 99, "abcdef ABCDE" )

strSearchFor = Ask_String("Search for:", "String_Find", 1, 99, "bc")

nFirstIndex = String_Find_First( strOriginal, strSearchFor, TRUE )

nLastIndex = String_Find_Last( strOriginal, strSearchFor, TRUE )

strTitle = String_Combine( "Search """, strOriginal )

strTitle = String_Combine( strTitle, """ for """ )

strTitle = String_Combine( strTitle, strSearchFor )

strTitle = String_Combine( strTitle, """" )

strMessage = String_Combine( "String_Find_First: ", Number_To_String_Decimal( nFirstIndex ) )

Ask_OK( strMessage, strTitle )

strMessage = String_Combine( "String_Find_Last: ", Number_To_String_Decimal( nLastIndex ) )

Ask_OK( strMessage, strTitle )

Return

See Also

String_Length, String_Find_Last, String_Equal, String_Set

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal