Difference between revisions of "FindSubString"

From NWN Lexicon
Jump to: navigation, search
m (Wikified article formatting)
 
Line 1: Line 1:
 
 
 
 
=FindSubString(string, string)=
 
 
 
Returns the position of sSubstring in sString.
 
Returns the position of sSubstring in sString.
  
Line 15: Line 9:
 
</nwscript>
 
</nwscript>
  
====Parameters====
+
===Parameters===
  
''sString''
+
; sString
 +
: The string you are searching within.
  
The string you are searching within.
+
; sSubString
 +
: The string you are searching sString for.
  
''sSubString''
+
; nStart
 +
: The character position to start searching at (from the left end of the string). (Default = 0)
  
The string you are searching sString for.
+
===Description===
  
''nStart''
+
Returns an integer value representing the position of sSubstring in sString. The search is case sensitive.
  
The character position to start searching at (from the left end of the string). (Default = 0)
+
Returns a base zero index of where sSubstring starts in sString if found.
  
<br />
+
Returns -1 if sSubstring is not found to exist in sString.
  
====Description====
+
===Version===
 
 
Returns an integer value representing the position of sSubstring in sString. The search is case sensitive.<br /><br /> Returns a base zero index of where sSubstring starts in sString if found.<br /><br /> Returns -1 if sSubstring is not found to exist in sString.<br />
 
 
 
<br /><br />
 
 
 
====Version====
 
  
 
1.69
 
1.69
  
====Example====
+
===Example===
  
 
<nwscript>
 
<nwscript>
 
//Example 1 - The following would return a value of 0.
 
//Example 1 - The following would return a value of 0.
  int nPostion = FindSubString("testing","test");
+
int nPostion = FindSubString("testing","test");
  
 
//Example 2 - The following would return a value of 1.
 
//Example 2 - The following would return a value of 1.
  int nPostion = FindSubString("testing","est");
+
int nPostion = FindSubString("testing","est");
  
 
//Example 3 - The following would return a value of -1.
 
//Example 3 - The following would return a value of -1.
  int nPostion = FindSubString("testing","mike");
+
int nPostion = FindSubString("testing","mike");
  
 
//Example 4 - The following would return a value of -1.
 
//Example 4 - The following would return a value of -1.
  int nPostion = FindSubString("testing","Test");
+
int nPostion = FindSubString("testing","Test");
  
 
//Example 5 - The following would return a value of 4.
 
//Example 5 - The following would return a value of 4.
  int nPostion = FindSubString("testing","ing", 4);
+
int nPostion = FindSubString("testing","ing", 4);
 
 
 
//Example 6 - The following would return a value of -1.
 
//Example 6 - The following would return a value of -1.
  int nPostion = FindSubString("testing","ing", 5);
+
int nPostion = FindSubString("testing","ing", 5);
 
 
 
</nwscript>
 
</nwscript>
  
====See Also====
+
===See Also===
  
 
{| class="seealso"
 
{| class="seealso"
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
|
+
|[[TestStringAgainstPattern]]()
[[ TestStringAgainstPattern  | TestStringAgainstPattern ]]
 
 
|-
 
|-
 
|}
 
|}
  
<br />
 
 
----
 
----
<font color="gray">  author: Brett Lathrope, editor: Mistress</font><br />  <br />
+
<font color="gray">  author: Brett Lathrope, editor: Mistress</font>
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:String_Functions]]
 
[[Category:String_Functions]]
 +
{{DISPLAYTITLE:FindSubString(string, string)}}

Latest revision as of 07:56, 5 July 2019

Returns the position of sSubstring in sString.

int FindSubString(
    string sString,
    string sSubString
    int nStart = 0
);

Parameters

sString
The string you are searching within.
sSubString
The string you are searching sString for.
nStart
The character position to start searching at (from the left end of the string). (Default = 0)

Description

Returns an integer value representing the position of sSubstring in sString. The search is case sensitive.

Returns a base zero index of where sSubstring starts in sString if found.

Returns -1 if sSubstring is not found to exist in sString.

Version

1.69

Example

//Example 1 - The following would return a value of 0.
int nPostion = FindSubString("testing","test");
 
//Example 2 - The following would return a value of 1.
int nPostion = FindSubString("testing","est");
 
//Example 3 - The following would return a value of -1.
int nPostion = FindSubString("testing","mike");
 
//Example 4 - The following would return a value of -1.
int nPostion = FindSubString("testing","Test");
 
//Example 5 - The following would return a value of 4.
int nPostion = FindSubString("testing","ing", 4);
 
//Example 6 - The following would return a value of -1.
int nPostion = FindSubString("testing","ing", 5);

See Also

functions:  TestStringAgainstPattern()

 author: Brett Lathrope, editor: Mistress