indexOf()

From Hack Wars Wiki

Jump to: navigation, search


Information for free function indexOf()
Function indexOf(string str, string find, int offset)
API Attacking, Banking, FTP, Watch, HTTP, Challenges, Hacktendo
Description Returns the position of 'find' in the 'str' string, starting from the nth character which is also know as the offset.


If 'find' is not found in 'str' indexOf() returns -1.
The third parameter and the returned value start counting with 0 as the the first character of a string.

Example

The following Challenge example will return the index of the comma in "Hello, world". Although the comma is the sixth character indexOf() returns 5 because it starts counting with 0.

string lineStr = "Hello, world.";
int linePos = indexOf(lineStr, ",", 0);
setOutputInt(linePos);


Output:

 5
Personal tools