Strfind

strfind

Description:
Function strfind search for a sub string in a string.
This function name starts with a lowercase letter.


Parameters:
(const string[], const sub[], bool:ignorecase = false,pos = 0)
string string The string you want to search in (haystack).
string sub The string you want to search for (needle).
bool ignorecase When set to true, the case doesn't matter - HeLLo is the same as Hello. When false, they're not the same.
int pos The offset to start searching from.


Return Values:
The number of characters before the sub string (the sub string's start position) or -1 if it's not found.


Examples:
if(strfind("Are you in here?", "you", true) != -1) //returns 4, because the start of 'you' (y) is at index 4 in the string
{
    SendClientMessageToAll(0xFFFFFFFF, "I found you!");
}


Related Functions
The following functions may be useful, as they are related to this function in one way or another.
  • strlen: Get the length of a string.
  • strpack: Pack a string. Packed strings use 75% less memory.
  • strunpack: Unpack a string.
  • strcat: Concatenates (joins together) two strings into the destination string.
  • strmid: Extract a range of characters from a string.
  • strins: Insert a string into another string.
  • strdel: Delete part of a string.
  • strcmp: Compares two strings to see if they are the same.
  • strval: Convert a string to an integer.
  • valstr: Convert an integer into a string.
  • ispacked: Checks if the given string is packed.
  • uudecode: Decode an UU-encoded string.
  • uuencode: Encode a string to an UU-decoded string.
  • memcpy: Copy bytes from one location to another.