strFind Function

Searches a string for the first occurrence of one of the specified characters.


int strFind(
    str _text, 
    str _characters, 
    int _position, 
    int _number)

Parameter

Description

_text

The string to search.

_characters

The characters for which to search.

_position

The position in the string where the search begins.

_number

A signed number that indicates the direction of the search and how many positions to search in the string.

The value of the position of the first occurrence of one of the specified characters.

To search from the beginning of the string to the end, use 1 as the value of the _position parameter.

If the value of the _number is negative, the system searches the number of characters backward from the specified position.

The search is not case-sensitive. For example:

  • strFind(“abcdef”, “D”, 3, 02) //Returns 4.

  • strFind(“abcdef”, “Bf”, 3, -2) //Returns 2.

  • strFind(“abcdef”, “Z”, 3, 2) //Returns 0.

  • strFind("ABCDEFGHIJ","KHD",1,10); //Returns the value 4 (the position where "D" was found).

  • strFind("ABCDEFGHIJ","KHD",10,-10); //Returns the value 8 (the position where "H" was found).

The strFind function is complementary to the strNFind function.

Community Additions

ADD
Show: