Difference between revisions of "Find - StringUtil"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>JohnB
imported>Qqqbbb
 
Line 13: Line 13:
== Parameters ==
== Parameters ==
*str: The string in which to search.
*str: The string in which to search.
*toFind: The string to looking for.
*toFind: The string to look for.
*startIndex: An optional index at which the function should start looking.
*startIndex: An optional index at which the function should start looking.
**'''Default''': 0
**'''Default''': 0

Latest revision as of 16:44, 1 December 2013

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)

Syntax[edit | edit source]

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

Parameters[edit | edit source]

  • 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 Value[edit | edit source]

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

Examples[edit | edit source]

; 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

Notes[edit | edit source]

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

See Also[edit | edit source]