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

Java: IndexOf(String string) that returns wrong character

I am writing a file browser program that displays file directory path while a user navigates between folders/files. I have the following String as file path: "Files > Cold Storage > C > Capital" I am using Java indexOf(String) method to return the…
blueware
  • 5,205
  • 1
  • 40
  • 60
0
votes
2 answers

Using indexOf() to search array inside ng-repeat

I'm try to search an array of id's [1, 2, 3] with indexOf() inside an ng-repeat loop, but probably because of a wrong data type, it doesn't work.
  • Member ID: {{ member.id }}
    Philip
    • 5,011
    • 2
    • 30
    • 36
  • 0
    votes
    1 answer

    Bash script to extract substring, convert to integer

    I am in the process of writing a Bash script which executes a command that returns strings bearing the form /folder/file_NNNN llll.killAt="nn...nn" I want to do the following extract the numeric part in quotes after .killAt= compare it against the…
    DroidOS
    • 8,530
    • 16
    • 99
    • 171
    0
    votes
    2 answers

    Java ArrayList indexOf returns -1

    I have a strange problem with my code. Heres the code I test the Chunk class with: List chunks = new ArrayList(); chunks.add(new Chunk(1,1,1)); System.out.println(chunks.indexOf(new Vector3i(1, 1, 1))); And here is the Chunk class'…
    KaareZ
    • 615
    • 2
    • 10
    • 22
    0
    votes
    1 answer

    jQuery - Using indexOf() with match()

    I am currently working on an user script made for YouTube using Firefoxs addon 'Greasemonkey' and came across a deadend.. Is it possible to check the url whether or not the url contains a specific string? I tried using indexOf() along with match()…
    Dean
    • 301
    • 1
    • 3
    • 13
    0
    votes
    1 answer

    Why is this splice removing the wrong item in my ng-repeat?

    I'm trying to splice out items in this ng-repeat based on their $index. It works for adding them just fine, but when I try to delete that item using that same code it removes only the last item of the array as if it were doing the pop() method. I…
    JoshPMP
    • 31
    • 2
    • 7
    0
    votes
    3 answers

    Querying complex json

    I have JSON that has to conform to this standard. { "level": [ { "1": { "Title": "My First Title", "Body": "My First Body" } }, { "2": { "Title": "My Second Title", "Body": "My Second…
    Nicholas Mordecai
    • 859
    • 2
    • 12
    • 33
    0
    votes
    9 answers

    array.indexOf is just -1

    got that code: var itemGrid = [3,4,2,11,1,3,5,8,6]; var a = itemGrid.indexOf(0); a is everytime -1. It should be 3. What did I do wrong? fiddle: http://jsfiddle.net/okg9g4tt/
    Standard
    • 1,450
    • 17
    • 35
    0
    votes
    2 answers

    Complex Hashmap ArrayList Generator

    Here's some code: ArrayList List = new ArrayList<>(); Map > map = new HashMap>(); List.add("stringA"); List.add("stringB"); List.add("stringC"); for(int i = 0; i
    REAL O G
    • 693
    • 7
    • 23
    0
    votes
    4 answers

    How to get indexOf of matching chracters

    I want to get indexOf of all occurring characters. For Example, I have a variable a var a = "aabaaababaa"; I want to get indexOf for all characters in a I tried: for(i = 0; i < a.length ;i++){ var len = a.indexOf(a); console.log(len); } But…
    Skyyy
    • 1,539
    • 2
    • 23
    • 60
    0
    votes
    4 answers

    Java Arraylist.contains(Object) always returns false

    Basically i want to create a class "Screws". This class shall describe a Screw by Type, length, thickness etc. I also want to create a "storage" class, that stores said "Screws" in all variances. The type, length etc. is limited to 7 and 3 (so there…
    Shenanigator
    • 17
    • 1
    • 6
    0
    votes
    4 answers

    Is there a better way to divide this string into substrings?

    I am trying to extract the "first_name" and "last_name" from a long string of information that look like this: { "123123123": { "id": "12321312****", "email": "***************", "first_name": "Marcus", "gender":…
    0
    votes
    3 answers

    Find item in array with indexOf

    I have a problem with 'indexOf'. When i pass a numerical value in argument, it works, but not with a variable: $.ajax({ url: 'bdd.php', type: 'POST', data: {'jsonNomCommune': jsonNomCommune, 'client': client}, success: function(data)…
    Kroll
    • 105
    • 1
    • 10
    0
    votes
    2 answers

    Is there a ways to check for multiple values on an array?

    I'm using indexOf to check a JSON twitter feed for certain strings. I want to have the ability to have multiple strings trigger the same event. I wrote a switch that works if you're only looking for a single property in the array, but can't find a…
    Rob McCoy
    • 43
    • 1
    • 1
    • 4
    0
    votes
    1 answer

    Is there a better way to get dom index in Dojo?

    im used to use jquery .index() and need some help to understand how to works Dojo Nodelist. My code:
    1 2 3
    99
    100