indexof

jQuery Ajax How Do I Pass responseText as variable to indexOf?

Hello, I am trying to append a p element from the responseText of an Ajax request. Before appending, I would like to see if the responseText already exists in the parent div element text, and not add it if that is the case. The problem is I cannot get indexOf(responseText) to work using the variable responseText. My code works when ...

Javascript, string: test string for presence of sub-string that includes an asterisk (*)

I'm doing a pretty basic string matching test as follows: if(msList.indexOf(textChoice) != -1) This works well except that occasionally the sub-string I'm looking for (textChoice) ends with an asterisk. Then I end up getting false matches because the asterisk in the string is interpreted as an operator, not a character in the string. ...

find out if AS3's XMLList contains string as node value

Is there an XMLList equivalent to Array.indexOf? For example - var array:Array = ['one','two']; trace(array.indexOf('two')); // returns 1, since it's at the second position trace(array.indexOf('three')); // returns -1, since it isn't found ... right? but what if I've got this - var xml:XML = <list><item>one</item><item>two</item><...

Search for all instances of a string inside a string.

Hello I am using indexOf method to search if a string is present inside another string. But I want to get all the locations of where string is? Is there any method to get all the locations where the string exists? <html> <head> <script type="text/javascript"> function clik() { var x='hit'; //document.getElementById('hideme').value =''; ...

How to find all occurrences of one string in another in JavaScript?

I'm trying to find the positions of all occurrences of a string in another string, case-insensitive. For example, given the string: I learned to play the Ukulele in Lebanon. and the search string le, I want to obtain the array: [2, 25, 27, 33] Both strings will be variables - i.e., I can't hard-code their values. I figured that th...

How to strip the last part of a query string

Hi all, I need to isolate an id in a string using javascript. I've managed to get to the part where I get to the id but then I want to be able to string the rest of the string so that it only leaves the id number such as this: var urlString = "http://mysite.co.za/wine/wine-blog/blogid/24/parentblogid/15.aspx"; // if the blogid ...

Why is this List<>.IndexOf code so much faster than the List[i] and manual compare?

I'm running AQTime on this piece of code, I found that .IndexOf takes 16% of the time vs close to 80% for the other piece... They appear to use the same IsEqual and other routines. Called 116,000 times inserting 30,000 items. None of the List<> objects gets over 200 elements. (I may be using AQTime incorrectly, I'm looking into this)...

Indexof with String array in vb.net

How would I find the index of an item in the a string array following code: Dim arrayofitems() as String Dim itemindex as UInteger itemindex = arrayofitems.IndexOf("item test") Dim itemname as String = arrayofitems(itemindex) I'd like to know how I would find the index of an item in a string array. (All of the items are lowercase, so ...

Why IndexOf returns always Zero?

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"&gt;&lt;/p&gt;&lt;p&gt;" Dim Idx as integer = Str.IndexOf("<p>") Is there any other way, of getting the index? ...

Why is indexOf not working in Internet Explorer?

This function executes during the forms onSubmit, and works fine in Firefox and Chrome, but not in IE. I suspect it's indexOf, but I cannot seem to find a way to get it to work. function checkSuburbMatch(e) { var theSuburb = document.getElementById('suburb').value; var thePostcode = document.getElementById('postcode').value; var array...

find the text and the strip the text at a certain point

I am trying to write this funtion to grab the text value and then strip the text from after the - symbol and the - symbol itself. eg some text - is found would become some text This is what iv got so far currently it just removes the - $.keynav.enterDown = function () { var accom = $('#suggestions p.keynavon').text().r...

Javascript Bind on Blur, Both 'if indexOf' and 'else' Performed

[Edit by Author - 10/27/2010 @ 08:49 AM CST ] HTML <!-- Contents of div #1 --> <form id="6hgj3y537y2biacb"> <label for="product_calendar" class="entry_label">Calendar</label> <input type="text" name="product_calendar" class="entry" value="" /> </form> <form id="pyc2w1fs47mbojez"> <label for="product_calendar" class="entry_l...

Why is List<T>.IndexOf() a lot faster than List<T>.Contains()?

Hello, I have List which has 150K elements. Average time of work IndexOf() is 4 times lower than Contains(). I tried to use List of int. For List of strings IndexOf is a bit faster. I found only one main difference, it's attribute TargetedPatchingOptOut. MSDN tells: Indicates that the .NET Framework class library method to which th...