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

trim everything before last slash vb.net

Yesterday I learned to trim the file name off a file location using the flowing code Dim NEWPATH As String = (inventorApp.ActiveDocument.FullFileName) NEWPATH = NEWPATH.Substring(0, NEWPATH.fIndexOf("\"c)) This is realy neat because it is a…
TM80
  • 123
  • 2
  • 2
  • 12
0
votes
1 answer

Cannot retrieve total indexof listview

I have a ListView control that I'm filtering results from with a TextBox. The code works for highlighting the backcolors of the matching results, but I want to get the total found results/highlighted objects as an int. The int that is populating now…
EyeSeeSharp
  • 604
  • 1
  • 8
  • 21
0
votes
2 answers

specific bug in code when iterating using indexOf() Javascript

I have been going through the FreeCodeCamp's Bonfire algorithm challenges, and with this particular challenge we are given two parameters and asked to use indexOf() to match up all of the characters from the second parameter's string with the first…
0
votes
2 answers

Slicing an Argument on Filter Array?

I have been doing this course for hours on free code camp, however, I found a solution that I do not understand and I am trying to put comments on each line to record as I achieve and understand it for future references and I already understand some…
0
votes
0 answers

Tree Control can't get index of node (SAPUI5)

Good morning, I got a problem with my Tree control in SAPUI5. At first I'll give you a short code snippet: loadChildNodes : function(parentID){ if (parentID != "" && parentID != "_1") { var oTree =…
Chris
  • 599
  • 3
  • 11
  • 24
0
votes
2 answers

Why the var count increasing in the code ?? however i mentioned if(vowel.indexOf(item !== -1))

Why the var count increasing in the code ?? however i mentioned if(vowel.indexOf(item !== -1)). document.write('
');
function func7solve(str)
    {
        var vowel= "aeiouAEIOU";
        var arr = str.split("");
        var count = 0;
…
0
votes
1 answer

Qt5.5 QByteArray indexOf mid wrong result

I have an XML file in a QByteArray I am using the indexOf method to find a string in the array, but the position returned isn't correct. If I examine the data content using qDebug I can see that the data has escape characters which isn't a problem…
SPlatten
  • 5,334
  • 11
  • 57
  • 128
0
votes
1 answer

Powershell5 IndexOf behaviour changed - suggestions?

Having recently upgraded my workstation to Windows10 I've been checking all my old scripts and it seems that IndexOf is behaving differently. In PS4 this worked fine: $fullarray = $permissions | %{ $obj = new-object psobject $obj |…
Scepticalist
  • 3,737
  • 1
  • 13
  • 30
0
votes
4 answers

Implementing Java's indexOf method (Substring search)

I am only a second semester CS student and can't use any of the well known efficient substring search algorithms. I need to implement the indexOf method with the following method signature: int indexOf(String str, String pattern) which returns the…
Mutating Algorithm
  • 2,604
  • 2
  • 29
  • 66
0
votes
1 answer

Index out of range (Can't get in the if condition)

I am making a vocab app. User will be asked to choose a date, And after tapping one of date, prepareForSegue() will pass an array that contains about 30 vocabs, to ViewController. Then this viewController begin to display a vocab label, after one…
Janghyup Lee
  • 167
  • 3
  • 17
0
votes
2 answers

Shorter way to acces object id?

I have an array of objects like this: var locations = [ [{id: 1, lat: 51.52376322544537, lng: 5.13785702262885, content: 'Title A'}], [{id: 2, lat: 51.52358632767757, lng: 5.137921395645208, content: 'Title B'}], [{id: 3, lat: 51.52343946863126,…
Sireini
  • 4,142
  • 12
  • 52
  • 91
0
votes
2 answers

An Issue About indexOfFunction

Let's say we'have code like that; String s = "ali trees tree"; System.out.println(s.indexOf("tree")); The output is 4. It's the beginning position of "trees". "Trees" word includes "tree" and I think because of that it gives wrong result. Is it a…
EkremC.
  • 61
  • 2
0
votes
1 answer

Javascript Cannot call method 'indexOf' of undefined at order

I need to make a function that will sort a string. Each word in the String will contain a single number. Numbers can be from 1 to 9(no 0). For example an input: "is2 Thi1s T4est 3a" the function should return "Thi1s is2 3a T4est". My code is : …
wendy
  • 161
  • 3
  • 14
0
votes
1 answer

Positional index implementation in JAVA

I'm creating a positional index using Java, which has the documentID and the position of the word eg : If we have a scenario which has three documents a document String[] docs = {"put new returns between paragraphs", "houses which are new in…
shockwave
  • 3,074
  • 9
  • 35
  • 60
0
votes
2 answers

return a substring using indexOf as a parameter within a function

I'm supposed to create a functions to test a URL for validity then functions to look for and return parts of the URL string based on location of certain characters (position would be unknown). FYI, I'm very new to programming but have been searching…
Tyzer
  • 3
  • 1
  • 4