Strfind

From SA-MP Wiki

Jump to: navigation, search

Strfind


Can be used to search for a sub string in a string.


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


ReturnsThe position of the sub string or -1 if it's not found.


new instring = strfind("Are you in here?", "you", true); //returns 4

Related Functions

The following functions might be useful as well, as they're related to this function in one way or another.

Any functions here can also be found on the Old scripting functions page.

  • strcmp: Compare two strings to see if they are the same.
  • strtok: Search for a variable typed after a space.
  • strdel: Delete part/all of a string.
  • strins: Put a string into another string.
  • strlen: Check the length of a string.
  • strmid: Extract characters from a string.
  • strpack: Pack a string into a destination.
  • strval: Find the value of a string.
  • strcat: Contact two strings into a destination reference.
Personal tools