indexof

Remove domain information from login id in C#

I would like to remove the domain/computer information from a login id in C#. So, I would like to make either "Domain\me" or "Domain\me" just "me". I could always check for the existence of either, and use that as the index to start the substring...but I am looking for something more elegant and compact. Worse case scenario: ...

Is there a version of JavaScript's String.indexOf() that allows for regular expressions?

In javascript, is there an equivalent of String.indexOf() that takes a regular expression instead of a string for the first first parameter while still allowing a second parameter ? I need to do something like str.indexOf(/[abc]/ , i); and str.lastIndexOf(/[abc]/ , i); While String.search() takes a regexp as a parameter it does n...

Question about overzelaous implementation of IndexOf

I have a priority queue implementation in C# that I want to add a .IndexOf method to. However, since the priority queue doesn't really concern itself with the order of the values themselves (that is, if I were to just grab all the values, disregarding their priorities, they wouldn't necessarily have any order at all), only the priority ...

Actionscript indexOf problem

When I create a TextField in AS3 with multiline set to true and equate the text to say: "Hola \r hola" I am unable to retrieve the index position of \r using indexOf function, it always returns -1 Does anyone know what I'm doing wrong? var txt:TextField; txt.multiline = true; txt.text = "Hola \r hola"; //txt now renders fine with t...

What has higher performance used within large loops: .indexOf(str) or .match(regex)?

I have this array.prototype on my page and it seems to be sucking up a lot of processing time: Array.prototype.findInArray = function(searchStr) { var returnArray = false; for (i=0; i<this.length; i++) { if (typeof(searchStr) == 'function') { if (searchStr.test(this[i])) { if (!returnArray) { r...

IndexOf Feature in Pl/SQL

I'd like to look up the location of a specific character in a varchar variable. ...

.NET string IndexOf unexpected result

A string variable str contains the following somewhere inside it: se\"> I'm trying to find the beginning of it using: str.IndexOf("se\\\">") which returns -1 Why isn't it finding the substring? Note: due to editing the snippet showed 5x \ for a while, the original had 3 in a row. ...

IndexOf too slow on list. Faster solution?

Hello, I have generic list which must be a preserved order so I can retrieve the index of an object in the list. The problem is IndexOf is way too slow. If I comment the IndexOf out, the code runs fast as can be. Is there a better way, such as a preserved ordered hash list for c#? Thanks, Nate Edit - The order in which the items are a...

best way to find end of body tag in html

I'm writing a program to add some code to html files I was going to use a series of indexof and loops to find what is essentially ""X (where X is the spot im looking for) It occurred to me that there might be a more eloquent way of doing this does anyone have any suggestions. what it looks like currently <body onLoad="JavaScript:top...

How to get the index of an element in an IEnumerable?

I wrote this: public static class EnumerableExtensions { public static int IndexOf<T>(this IEnumerable<T> obj, T value) { return obj .Select((a, i) => (a.Equals(value)) ? i : -1) .Max(); } public static int IndexOf<T>(this IEnumerable<T> obj, T value , IEqualityComparer<T> comp...

DataTable Rows.IndexOf()

I am trying to find a row and then delete that row from a datatable. I keep getting nIndex = -1. Anyone have suggestions? protected void cbxSelected_CheckedChanged(object sender, EventArgs e) { CheckBox checkbox = (CheckBox)sender; GridViewRow row = (GridViewRow)checkbox.NamingContainer; string sSampleId = row.Cells[1].Text; if (!s...

How to use IndexOf() method of List<object>

All the examples I see of using the IndexOf() method in List are of basic string types. What I want to know is how to return the index of a list type that is an object, based on one of the object variables. List<Employee> employeeList = new List<Employee>(); employeeList.Add(new Employee("First","Last",45.00)); I want to find the inde...

how to return the character which is at the index ?

I know that i could return the index of a particular character of a string with indexof() function. But how i could return the character with the particular index? ...

How to continue from where I have been searching to find the index?

How to continue from where I have been searching to find the index? I am searching in a file to find the index of a character; then I have to continue from there to find the index of the next character. For example : string is " habcdefghij" int index = message.IndexOf("c"); Label2.Text = index.ToString(); labe...

IndexOf method returns 0 when it should had return -1 in C# / Java

A friend of mine came to me with this strange behavior which i can't explain, any insight view would be appreciated. Im running VS 2005 (C# 2.0), the following code show the behavior int rr = "test".IndexOf(""); Console.WriteLine(rr.ToString()); the above code, print "0" which clearly show it should have return -1 This also happen i...

How can I use IndexOf to pick a specific Character when there are more than one of them?

How can I use IndexOf with SubString to pick a specific Character when there are more than one of them? Here's my issue. I want to take the path "C:\Users\Jim\AppData\Local\Temp\" and remove the "Temp\" part. Leaving just "C:\Users\Jim\AppData\Local\" I have solved my problem with the code below but this assumes that the "Temp" folder is...

ArrayList of my objects, indexOf problem

Hello! I have problem with Java's ArrayList. I've created an Object, that contains two attributes, x and y. Now I've loaded some object in my ArrayList. Problem is that I don't know how to find index of some object with x atribute I'm searching. Is there any way to do this? ...

Array indexOf implementation for Internet Explorer

There are plenty of solutions on how to get the indexOf implementation into the Array prototype so that it works under Internet Explorer, however I've stumbled upon an issue that doesn't seem to be addressed anywhere I've looked so far. Using the pretty well agreed upon implementation at MDC, I have the following code that's being probl...

index of first alphabet in sqlserver

Hi, how can we select the index of the first alphabet in a text column in sqlserver? ...

[VB.NET/C#] Finding position of an element in a two-dimensional array?

Well simple question here (maybe not a simple answer?) Say I have a two dimensional array [0] [1] [2] [3] [4] [5] [6] [7] [8] Now suppose I want to get the position of the number 6 I know with a one-dimensional array i can use Array.indexOf() but what would my options be with 2-dimensional arrays? Thanks! ...