Difference between revisions of "Find - StringUtil"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>JohnB
(Created page with "Category:Scripting Category:Papyrus Category:SKSE '''SKSE Member of:''' StringUtil Script Returns the index of the first occurence of specified phrase inside ...")
 
imported>JohnB
Line 18: Line 18:


== Return Value ==
== Return Value ==
Index of the first occurence of the specified string, or -1 if nothing was found.
Index of the first occurence of the specified string, or -1 if nothing was found.<br/>
Also returns -1 if the given startIndex was invalid.
Also returns -1 if the given startIndex was invalid.



Revision as of 17:39, 19 August 2012

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

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

Parameters

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

Return Value

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

; 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

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

See Also