Find - StringUtil

SKSE Member of: StringUtil Script

Returns the index of the first occurence of specified phrase inside given string, optionally starting on selected position. (This function requires SKSE)

SyntaxEdit

int Function Find(string str, string toFind, int startIndex = 0) global native

ParametersEdit

  • str: The string in which to search.
  • toFind: The string to look for.
  • startIndex: An optional index at which the function should start looking.
    • Default: 0

Return ValueEdit

Index of the first occurence of the specified string, or -1 if nothing was found.
Also returns -1 if the given startIndex was invalid.

ExamplesEdit

; looking for some words
String myString = "Apple Banana"
int index1 = StringUtil.Find(myString, "Banana")
; index1 = 6
int index2 = StringUtil.Find(myString, "e", 5)
; index2 = -1
int index3 = StringUtil.Find(myString, "Apple", 22)
; index3 = -1

NotesEdit

This function is case-insensitive (like all SKSE string functions right now).

See AlsoEdit