indexof

Inner While Loop only run once

走远了吗. 提交于 2019-12-12 03:14:49
问题 The purpose of the code is to find a portion of a string (from one document) in a long list of strings (another document), and return the results to a list. I have two while loops, one nested in the other. The outer loop reads each line of that document, and the inner reads each loop of its document. For some reason, the inner while only runs once (for the outer loop's first iteration). Can you explain why and how I could fix it? It seems like it only reads all the lines once and then doesn't

How to fetch string after the third slash in java

二次信任 提交于 2019-12-12 03:03:39
问题 I am trying to fetch the string after the third slash. But i don' know how to do it. I have used split but that's not what I want. for(String obj2: listKey.getCommonPrefixes()){ Map<String, String> map = new HashMap<String, String>(); String[] id = obj2.split("/"); if (id.length > 3) { String name = id[3]; map.put("id", name); map.put("date", "null"); map.put("size", String.valueOf(obj2.length())); keys.add(map); } } id[3] gives me only id[3] but i want everything after the third slash? how

How can I get a substring from the middle of a file path in VBScript?

纵然是瞬间 提交于 2019-12-12 01:16:55
问题 I have the following string in VBScript: myPath = "C:\Movies\12 Monkeys\12_MONKEYS.ISO" The path C:\Movies\ is always going to be the same. So here is another path as an example: myPath = "C:\Movies\The Avengers\DISC_1.ISO" My question is, how can I pull only the movie folder name, so in the above examples I would get: myMovie = "12 Monkeys" myMovie = "The Avengers" Is there a way to use RegEx with this? Or should I just do some substring and index calls? What is the easiest way to do this?

Select characters after index in order to select another element with the same characters

℡╲_俬逩灬. 提交于 2019-12-11 19:54:50
问题 I'm attempting to grab the characters after an index to use in selecting another input with the same last character(s). Currently I have the following error message : thisObj1.indexOf is not a function for thisObj and thisObj1 . I've tried to use a for loop and i with selector, however that resulted in all elements similar being affected. <input type="text" value="5" id="nosday"><br><br> <input type="hidden" value="3" id="countrows"><br> ////////////////////////FIRST FORM/////////////////////

Get coordinates of an element in multidimentional array in Javascript [duplicate]

≡放荡痞女 提交于 2019-12-11 15:28:41
问题 This question already has answers here : To find Index of Multidimensional Array in Javascript (3 answers) Closed 9 months ago . I want to where is placed an element in an multidimentional array like that : var letterVariations = [ [' ','0','1','2','3','4','5','6','7','8','9'], ['A','a','B','b','C','c','D','d','E','e',';'], ['Â','â','F','f','G','g','H','h','Ê','ê',':'], ['À','à','I','i','J','j','K','k','È','è','.'], ['L','l','Î','î','M','m','N','n','É','é','?'], ['O','o','Ï','ï','P','p','Q',

How do I find out the position of a char

我与影子孤独终老i 提交于 2019-12-11 14:09:31
问题 I've got an String ("Dinosaur") and I don't exactly know how, but how do I get the position of the char "o" and is it in all possible to get two positions like if my String was ("Pool") 回答1: As for your first question, you can use String#indexOf(int) to get the index of every 'o' in your string. int oPos = yourString.indexOf('o'); As for your second question, it is possible to get all positions of a given char by making a method which uses String.indexOf(int, int), tracking the previous index

Can I pass in one function for TObjectList.IndexOf, and another function for TObjectList.Sort?

狂风中的少年 提交于 2019-12-11 08:24:30
问题 Summarization: TList.IndexOf (TList defined in the unit Classes.pas) iterates linearly through the contained items, and compares the reference. TList.IndexOf (TList defined in the unit Generics.Collections.pas) also iterates linearly through the contained items, but uses a comparer to compare whether the items are equal. Both TList.Sort and TList.Sort can use a comparer. ================================================= For an instance of the TForceList type defined in the following unit, I

Complex if-statement in an textchanged event

寵の児 提交于 2019-12-11 07:29:30
问题 I want to realize a complex if-statement. The if-statement is in an textchanged event of a textbox. If the if-statement gives true, a pdf-file should be load. The problem is not how to load the PDF-file, thats works already fine, the problem is, how set the if-statement. There, the following conditions should be queried: At position 0 must be an "S", at position 1 must be an "E", at position 2 must be an "H", position 3 does not matter, position 4-7 represent a number and the number must be

Why IndexOf returns always Zero?

牧云@^-^@ 提交于 2019-12-11 06:07:06
问题 Could someone point me why the IndexOf returns always zero in the following text? Dim Str as string = "<p><img class=floatLeft width="330"src="http://www.com"></p><p>" Dim Idx as integer = Str.IndexOf("<p>") Is there any other way, of getting the index? 回答1: Because the first occurrence of <p> is at the beginning of the string, and strings (along with many other things) are zero-indexed. If you want to get the index of the last -occurring <p> , you can use Str.LastIndexOf("<p>") . If you want

Finding Sub-array within Array

二次信任 提交于 2019-12-11 03:41:32
问题 I have the Array array = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]; and I want to find the index of the sub array [1, 2, 3, 4] So it should return the value 0 but every time I try to do this, it returns -1 Here is what i tried: array.indexOf(1, 2, 3, 4); I know this is because the subarray i am searching for has commas in it. how can i fix this 回答1: Here is a quick and dirty solution which compares the arrays as strings: var array = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10,