Difference between revisions of "IndexOf"

From Catglobe Wiki
Jump to: navigation, search
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:String_Functions]]
+
{{HelpFiles}}

 
  
====indexOf====
+
==== indexOf ====
  
Returns a 0-based index of the first occurrence of a string in another string. Returns empty if there are no occurrences found.
+
Returns a 0-based index of the first occurrence of a string in another string. Returns empty if there are no occurrences found.  
  
'''Syntax'''
+
'''Syntax'''  
  
indexOf(''stringToSearchFor, stringToSearchIn'')
+
indexOf(''stringToSearchFor, stringToSearchIn'')  
  
'''Arguments'''
+
'''Arguments'''  
  
''stringToSearchFor'': is a string expression.
+
''stringToSearchFor'': is a string expression.  
  
''stringToSearchIn'': is a string expression.
+
''stringToSearchIn'': is a string expression.  
  
'''Return type'''
+
'''Return type'''  
  
number
+
number  
  
'''Example'''
+
'''Example'''  
  
string 1 = "is";
+
''number result =indexOf("is", "catglobe is tHe beSt"); ''
  
string s2 = "catglobe is tHe beSt";
+
''print(result); ''
  
number result =indexOf(s1, s2);
+
''//9 ''
  
print(result);
+
'''Availability'''
  
//9
+
Version 5.2
  
'''Availability'''
+
[[Category:String_Functions]]
 
 
Version 5.2
 
__NOTOC__
 
<!-- imported from file: 687.htm-->
 

Latest revision as of 05:21, 14 August 2024


indexOf

Returns a 0-based index of the first occurrence of a string in another string. Returns empty if there are no occurrences found.

Syntax

indexOf(stringToSearchFor, stringToSearchIn)

Arguments

stringToSearchFor: is a string expression.

stringToSearchIn: is a string expression.

Return type

number

Example

number result =indexOf("is", "catglobe is tHe beSt");

print(result);

//9

Availability

Version 5.2