Questions tagged [indexof]

indexof is a method in programming languages like Java, C#, JavaScript, etc. that returns the first occurrence of a letter in a string, or the first occurrence of an element in a list.

indexof returns the first occurrence of a letter or a substring in a string, or the first occurrence of an element in a list.

1975 questions
0
votes
4 answers

How to check how many specific results is in name indexed array

I'd like to check how many elements with name: "order" have value equal 1. my array: var…
luke9999
  • 151
  • 1
  • 3
  • 9
0
votes
2 answers

Java Substring - Extract the string contained in the next occurrence of quotes

The transaction response (string) looks like the below. { "errorId": "15eabcd5-30b3-479b-ae03-67bb351c07e6-00000092", "errors": [ { "code": "20000000", "propertyName":…
user2967948
  • 529
  • 2
  • 8
  • 23
0
votes
2 answers

ArrayList/LinkedList get First Index number

Is is possible to get out of an ArrayList the first number of the first index? Here's an Example: In there are 5 items: path = {0.5,5.0},{0.6,6.0},{0.7,7.0},{0.8,8.0},{0.9,9.0} And I want to get the number 5.0 out of {0.5,5.0}... I tried it with…
genaray
  • 1,080
  • 1
  • 9
  • 30
0
votes
1 answer

Is there a way to see if certain integers are in certain places within an arraylist?

For example, if an arraylist holds the values [1, 2, 3], is there any way to check if they are in that order using indexOf or any other way?
Trevor
  • 11
  • 4
0
votes
5 answers

Remove all elements from the initial array that are of the same value as the arguments followed by the initial array

There is an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments. Here is my code, but I am unable to solve the…
Uzma Khan
  • 139
  • 1
  • 3
  • 14
0
votes
2 answers

Accessing indexes of a string inside an array and taking the sum

Ok so I am trying to access each individual number in the strings inside of this array. var array = ['818-625-9945','999-992-1313','888-222-2222','999-123-1245']; var str = ""; for (i=0; i
JonathanMitchell
  • 400
  • 1
  • 2
  • 12
0
votes
2 answers

jquery indexOf very slow ..any other alternate solution?

I try to create search box for selected option (very large data - around 2000 option) indexOf method very slow ..any other solution ? Jquery Code : $('#textfortitlesearch').on('keyup', function() { var query =…
0
votes
1 answer

What should my Array+RemoveObject.Swift contain?

I am using a template project to try to build a new app. When I run the template project, I get an error saying: '[T] does not have a member named 'indexOf'. The existing code in the Array+RemoveObject.swift doc is: import Foundation public func…
0
votes
3 answers

How to strip the last part of a query string

I need to isolate an id in a string using javascript. I've managed to get to the part where I get to the id but then I want to be able to string the rest of the string so that it only leaves the id number such as this: var urlString =…
Sixfoot Studio
  • 2,951
  • 7
  • 26
  • 35
0
votes
1 answer

Arraylist not returning index correctly

Hello i have a Arraylist of ID's to which i am searching for match index of that ID i am doing this private int getCategoryPos(List list_ids, String category) { return list_ids.indexOf(category); } i am passing arraylist and category…
0
votes
1 answer

Capturing index of an array onclick with JavaScript

https://jsbin.com/zesegigego/edit?html,js,output I'm creating a word search puzzle and at the point where I want to implement functionality to allow the users to mark the words they find. I have an array of s which contain randomly generated letters…
0
votes
0 answers

LinkedList specific methods aren't recognised

So I've been working on a school project in Java regarding returning a frequency of words in a sentence. I started off using an array, and when I realised that wouldn't work, I switched to using a LinkedList. However, I've encountered a problem. I'm…
0
votes
1 answer

CustomList class, what is a good way to remove at a specified index?

I have created a CustomList class with some methods such as Add(), Set(), and RemoveAt(). This CustomList class is meant to mimic the behavior of the List<> class without actually using it. When debugging my program I noticed that when I input the…
crin
  • 53
  • 1
  • 11
0
votes
1 answer

vb.net indexof list of class

I'm having an issue in a large piece of code that I'm working on, so I created a short piece of code to show the issue. I created a class (stockstatus) that represents an inventory item . They have a part number (.part), a quantity (.qty), and a…
0
votes
1 answer

TypeError: text.indexOf is not a function

I was playing around with javascript trying to make a word searcher for strings. However, when i run the code i get TypeError: text.indexOf is not a function. I don't think there is a syntax error, or maybe i am completly missing something. var text…
Samuel Ridicur
  • 59
  • 2
  • 10