What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-06 21:00:04
javascript check if string contains at the begins with substring
var str = "We got a poop cleanup on isle 4."; if(str.indexOf("poop") !== -1){ alert("Not again"); } //use indexOf (it returns position of substring or -1 if not found) Add solution -
C# 2022-02-17 18:15:26
indexof c#
// To find the index of the first substring in a string use // 'IndexOf()' string str = "Hello World!" str.IndexOf("o"); // Output: 4 // You can give a starting index and a length to search at str.IndexOf("o", 6, 4); // Outp... Add solution -
Javascript 2022-02-06 16:10:31
.index of javascript
//indexOf getting index of array element, returns -1 if not found var colors=["red","green","blue"]; var pos=colors.indexOf("blue");//2 //indexOf getting index of sub string, returns -1 if not found var str = "... Add solution -
Javascript 2021-11-20 11:03:36
js return indicie of string of ceritn sub string
function getIndicesOf(searchStr, str, caseSensitive) { var searchStrLen = searchStr.length; if (searchStrLen == 0) { return []; } var startIndex = 0, index, indices = []; if (!caseSensitive) { str = str.toLowerCase(); ... Add solution -
Java 2021-11-15 23:16:17
how to get index of second occurrence java
String str = "itiswhatitis"; //returns the index of the first i in "is" str.indexOf("is"); //returns the index of the second occurence of i in "is" after the first str.indexOf("is", str.indexOf("is&... Add solution -
Javascript 2021-10-23 04:41:12
js indexof string
//indexOf getting index of array element, returns -1 if not found var colors=["red","green","blue"]; var pos=colors.indexOf("blue");//2 //indexOf getting index of sub string, returns -1 if not found var str = "... Add solution