Questions tagged [lastindexof]

125 questions
1
vote
3 answers

Printing last index of string in a string without using lastIndexOf method

Note: This question is asked for a school assignment. I fell I'm getting close to the true code, there are only a few points left to be taken care of. I am asked to write a method that receives two strings(s1 and s2) and checks whether s2 is in s1…
Firat
  • 381
  • 1
  • 5
  • 17
1
vote
1 answer

LINQ get last position of special char

i have a simple LINQ Query (linq to entities via EF) var QueueList = (from q in context.queues select new { Qid = q.id, Qname =…
Dave Stockinger
  • 139
  • 2
  • 18
1
vote
2 answers

Check if string contains string from an array then use that in LastIndexOf method

I want to check if my input string contains one of 3 strings and use it later on. Here's what I have so far: // this is just an example of 1 out of 3 possible variations string titleID = "document for the period ended 31 March 2014"; // the array…
escape_artist
  • 319
  • 1
  • 3
  • 13
1
vote
2 answers

how to fix Object doesn't support property or method 'indexOf'?

i have this situation: if (image.indexOf("/bob/") != -1 || image.indexOf("/grabs/") != -1 || image.indexOf("/") == image.lastIndexOf("/")) { alert('success'); } in IE8 i get Object doesn't support property or method 'indexOf' i could probably…
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
1
vote
1 answer

Qt5 Delete the suffix of a filepath

I'm trying to figure out the QString::lastIndexOf and QString::chop to delete a suffix off a file, so I can add one myself. However, I get weird output that doesn't make sense to me. Here's my test code: QString filename =…
1
vote
3 answers

Using Java's ArrayList lastIndexOf()

To make things simple, I have an ArrayList called "items" (which stores a string the user inputs) and this bit of code: int index = items.lastIndexOf("i am"); if (index >= 0) System.out.println("yay"); When I test it out, if I type in "i am" at the…
taote
  • 33
  • 4
1
vote
0 answers

c# LastIndexOf with few words

I'm trying to get LAST index of "hello world" in text string. string sourceText = "hello world. no yes what where hello world but not right in left hello world end of text"; string searchIndex = "hello world"; int…
Vegas Rico
  • 73
  • 9
0
votes
1 answer

How to sort a parallel array to get the greatest and smallest value

I have two parallel arrays. one is type String and the other, type int. I want to sort them in ascending order while maintaining data consistency, keeping them parallel, to get the entry with the greatest int value and the entry with the int lowest…
0
votes
1 answer

How can I break up the text after the # I shared in the image?

I will create a parametric structure I will take after each '#' with its extension. For example here I need to get two texts after #
0
votes
1 answer

Split a string (file name) using index position

I need to separate the file name into an array of two strings. The file name looks like this: IMG-20190604-WA0005.jpg An array that I want: [0] = "IMG-20190604-WA0005" [1] = "jpg" I got index position using LasIndexOf('.')
Domagoj Hamzic
  • 300
  • 3
  • 17
0
votes
0 answers

Why does this code work in finding the first non-duplicate letter in a string?

I'm doing some self practice with Javascript. I'm working on a question that asks me to find the first letter in a string that does not have a duplicate. After some playing around, I finally got it to work using indexOf and lastIndexOf. But even…
0
votes
2 answers

Implement a delete button for a JavaScript calculator

I'm learning JavaScript(jQuery), so I'm working on a scientific calculator. The delete button works fine when I have input such as; sin(cos(tan(. But when I have a repetition of similar input, say; sin(cos(tan(sin(, it removes the first occurrence…
Bryan Somto
  • 101
  • 6
0
votes
5 answers

String index out of range on space bar character

For example the name Donald trump (12 character) brings up the error string index out of range 7 (where the space is found) even though the name Donald trump is longer. package test; import javax.swing.JOptionPane; public class Usernamesubstring…
0
votes
1 answer

I cant understand this lastindexof method in Java 11

int a="abcd".indexOf("d",0); int b="abcd".indexOf("d",1); int c="abcd".indexOf("d",2); int d="abcd".indexOf("d",3); int e="abcd".indexOf("d",4); int f="abcd".indexOf("d",5); int b1="abcd".indexOf("d",-1); int…
alex K
  • 81
  • 1
  • 1
  • 5
0
votes
2 answers

How would I detect the last two occurrence of characters/data sets in a text file c#

I have these text files as structured: value1 value2 value3 Table1 Table2 Table3 (data set values here) . . .(represent text in between) . value1 value2 value3 Table1 Table2 Table3 (data set values here) and value1…
1 2 3
8 9