Questions tagged [lastindexof]

125 questions
2
votes
0 answers

Function only grabbing the last index of the array in code.org program

I'm trying to help the kiddo with her AP project, her teacher said she can ask anyone for help, except her teacher. I went through her code but I don't understand her program, I wanted to know if anyone in here could help out. Thankfully it's not…
Felipe
  • 21
  • 2
2
votes
2 answers

How to return a widget if it is the last index of a list?

i want to retun a widget if it is the last item in the method but i get an error ... Tried calling: call() itemList.last() ? CircleAvatar( backgroundColor: mainColor, radius: 15, child: Icon(Icons.done), ) :…
ialyzaafan
  • 378
  • 6
  • 21
2
votes
2 answers

Understanding indexOf and lastIndexOf

I'am doing some JavaScript exercises and I stumbled upon this one "Write a JavaScript program to filter out the non-unique values in an array." I tried and found a solution, which worked but it was to cumbersome. A better answer, according to the…
Ahmed
  • 41
  • 4
2
votes
6 answers

Is it okay to use for in loop on a string?

Just wondering if its acceptable to use a for in loop on a string. Not sure if there could be weird results or bad practice but my solution works at least in this example. Coding practice question. Also, if anyone has a way to improve my solution…
Joe Spinelli
  • 105
  • 1
  • 11
2
votes
2 answers

Javascript - Find position of specific occurrence of a word in a string (not first or last)

if I have a string which has a lot of times the same word, lets say: "new question, new topic, new query, new code, new language, new answer" Here we have the word "new" 6 times, but i want to find the position of the 4th "new". I know IndexOf…
edwin26
  • 23
  • 2
2
votes
3 answers

For loop inside a string to concatenate the characters in a variable (without RegExp)- Javascript

I am trying to loop through a string variable and save every char inside an other variable. My code looks like this: var str = "hello world"; var res = ""; for (var i = str.indexOf("hello"); i <= str.lastIndexOf("hello"); i++) { …
Manos Z
  • 25
  • 1
  • 5
2
votes
2 answers

.NET CultureInfo.InvariantCulture.CompareInfo IndexOf vs LastIndexOf - What is going on?

In our app I wanted to be good citizen and transfer from culture-aware string comparisons to some deterministic comparisons in InvariantCulture, but because of that my app started crashing with OutOfMemory because of infinite cycle. It all comes…
Jacob
  • 627
  • 6
  • 15
2
votes
1 answer

Find the last occurrence of substring in string in a large text file

I'm trying to read through a huge text file, approx 10 gigabytes. I want to find the last occurrence of a string. e.g below is a sample of 5 lines the 2nd and 5th are the same string. I want to take the last one as it is the latest and output that…
vbvirg20
  • 115
  • 12
2
votes
1 answer

TextBox Indexof and LastIndexOf

Because TextBox doesn't have a find function, I've created and modified my own version of it to my needs. I've created to functions. One for Search Next and another for Search Previous My problem is that: If my search term is more than 1 character…
Zer0
  • 1,002
  • 1
  • 19
  • 40
2
votes
2 answers

Select text from a Richtextbox in C#

I want to select the text that is between the last '{' and '}' of a richtextbox text. I have the next code, but I have an error on the "LastIndexOf" function and I don't know how to fix it. Can someone give me some help? private void…
Imrik
  • 674
  • 2
  • 14
  • 32
2
votes
3 answers

Finding the nth occurrence of a character in a String using IndexOf()

I have a question regarding indexOf(). I am trying to program an EmailExtractor (Yes, this is a homework but I am not looking for code) which extracts the entire email address from a sentence that is input by a user. For example - User Input: Mail…
Kayjaeemm
  • 31
  • 2
  • 3
2
votes
1 answer

boost::algorithm::string::finder.hpp

Already asked this question and received answers about c++ STL but what about boost? This is a question about boost Finders. If you have a link to describable boost library implementations I would appreciate it to make hunting the boost library for…
Mushy
  • 2,535
  • 10
  • 33
  • 54
2
votes
3 answers

Java-like lastIndexOf in c++

I performed some research on boost and c++ but could not locate anything relevant to my question. Is there an boost library or STL function that implements lastIndexOf?
Mushy
  • 2,535
  • 10
  • 33
  • 54
2
votes
2 answers

How do you determine the current directory in a path string?

The Question: How do you determine a variable length string inbetween two similar characters? Allow me to clarify: take the two URLs: /designs/2012/mobile/v4/~html/ecom/ /designs/2012/mobile/v4/~html/legal/ I'm trying to build an anchor with an ID…
David Vasquez
  • 1,163
  • 1
  • 15
  • 22
2
votes
3 answers

ArgumentOutOfRangeException when using lastIndexOf()

I'm really stumped as to why I'm getting an exception. Here is a SSCCE I put together to demonstrate: static void Main(string[] args) { string tmp = "Child of: View Available Networks (197314), Title: N/A (66244)"; …
David Kroukamp
  • 36,155
  • 13
  • 81
  • 138
1
2
3
8 9