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
2 answers

How do I check strings in a 2D array column?

I have a 2D array with a list of names and numbers. Column 1 contains all the names of people. How do I edit my function to take user input and check to see if the input matches or if the input is partially found inside one of the names in one of…
Daniel O A
  • 145
  • 7
0
votes
3 answers

Python Removing a sublist in a list without changing the index of other sublists in the list

Say for example: list = { [1,2,3],[4,5,6],[3,4],[2,7,8,9] } is there a way in python to remove a sublist and make sure that other sublists index's remain the same. So for example if i was to remove the sublist [3,4], could i make sure that the…
user3602783
0
votes
2 answers

ArangoDB Getting the Index of a Document

Is there a way to get the index of a particular document in ArangoDB so as to use it in a LIMIT operation? For instance, let's say I look up a Document by it's ID and find that it's index is 534, then I would use that like this: LIMIT 534,…
skinneejoe
  • 3,921
  • 5
  • 30
  • 45
0
votes
1 answer

How to remove item inside JPanel which is designated by an ArrayList

There is a JPanel with GridLayout which is randomly populated by JButtons created using an ArrayList. Each element of the array (a Tile) contains a character. It's supposed to be a tile removing game. However, I realised that the code I wrote didn't…
user5495774
0
votes
2 answers

How to find the first occurance of a string that begins with "COM" in an array

Is there a built in way to do this or do i have to write my own loop? I have tried the code below: int index = Array.IndexOf(options, ind => ind.Contains("COM")); But it gives the following error: can not convert lambda to type object. This code…
0
votes
3 answers

Strict Filter Array of Arrays

I have a tags input box, similar to this except I need to restrict it to allowable combinations. Here is an example of the possible combinations: [{ "Combo": [ { "Id": 1, "Name": "Tag1" }, { …
ajpetersen
  • 639
  • 8
  • 17
0
votes
1 answer

how to check input .indexOf for multiple characters?

I am trying to check if the user enters at least one number. If yes, the output = 'okey' else 'no number'. This works only for the first number, however when I enter 2, the function answers 'no number'. Any ideas? thanks! var firstName =…
mad.mix
  • 53
  • 1
  • 2
  • 12
0
votes
1 answer

Pig Latin Converter Issue

Im working on a function that converts a normal word to pig latin, and I can't get everything to come together; it has to work for california, gloves, and eight. What isn't working right? function translate(word) { var result = ""; …
0
votes
1 answer

Override an array element value by matching with another array javascript

array1 has parent with children. array2 has few other children of parents in array1. array1 children should be replaced by children in array2 array1: { "name": "USA", "id": "country: USA", "children": [ { "name":…
Mustang
  • 604
  • 2
  • 13
  • 32
0
votes
3 answers

How to read multiple Strings off the same line via the scanner Without Split();

.split() Method is NOT Allowed I was got some help earlier from a helpful guy! I was just wondering if anyone could help me modify this a little bit more, The code is meant for an assignment and It is based on the input from the scanner. It has two…
Jon Roy
  • 53
  • 1
  • 11
0
votes
0 answers

Weird behavior with GET and substring

So I made this piece of code: options = getURL("http://florens.be/EnterRoomAlert/options.txt"); soundOptionStartPos = options.indexOf("sound") + 6; soundOptionEndPos = options.indexOf("e", soundOptionStartPos) + 1; soundOptionResult =…
Florens
  • 91
  • 12
0
votes
2 answers

IndexOf is missing a value in an array

I realize that IndexOf will return a -1 when it doesn't find a value within an array, however, the value that I have it searching for is in the array. I have confirmed this by returning the value in the array with console.log Here is some of my code…
CdnXxRRODxX
  • 341
  • 5
  • 14
0
votes
1 answer

Use indexOf for 2D array in java

Hello I create a 2D array and i want to find the position from the first 2 in the array. And after to add the index in a new ArrayList. But this code doesn't work. Any idea for the problem? import java.util.ArrayList; class Test { public static…
user3741098
0
votes
1 answer

Why is indexOf not recognized in my .ascx file (Sharepoint 2010)?

I have this code in my Sharepoint app: function upsertPostTravelListItemTravelerInfo1() { var clientContext = SP.ClientContext.get_current(); var oList = clientContext.get_web().get_lists().getByTitle('PostTravelFormFields'); …
0
votes
4 answers

Javascript Search for a match and output the whole string that the matching word is apart of

how would you go about outputting the found output, including the rest of the string its apart of? The array is just full of strings. Thanks var searchingfor = document.getElementById('searchfield').value; var searchingforinlowerCase =…