问题标签 [indexof]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
7 回答
3627 浏览

c# - 在html中找到body标签结尾的最佳方法

我正在编写一个程序来向 html 文件添加一些代码

我打算使用一系列 indexof 和循环来找到本质上是“”X(其中 X 是我正在寻找的位置)

我突然想到,可能有一种更雄辩的方式来做到这一点

有没有人有什么建议。

目前的样子

我完成后应该是什么样子


0 投票
12 回答
232469 浏览

c# - 如何获取 IEnumerable 中元素的索引?

我写了这个:

但我不知道它是否已经存在,是吗?

0 投票
2 回答
17386 浏览

c# - 数据表行.IndexOf()

我试图找到一行,然后从数据表中删除该行。我不断得到 nIndex = -1。有人有建议吗?

0 投票
6 回答
101872 浏览

c# - 如何使用 List 的 IndexOf() 方法

All the examples I see of using the IndexOf() method in List<T> are of basic string types. What I want to know is how to return the index of a list type that is an object,

All the examples I see of using the IndexOf() method in List<T> 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.

I want to find the index where employeeList.LastName == "Something"


Instead of making ld report the undefined symbols during linking, you could use nm on the resulting .so file. For example:

EDIT: Though I guess that doesn't give you which source files the symbols are used in. Sorry I missed that part of your question.

You could still use nm for an approximate solution, along with grep:

This might have problems with local symbols of the same name, etc.

0 投票
2 回答
154834 浏览

c# - 如何通过索引获取字符串中的字符?

我知道我可以使用该indexof()函数返回字符串的特定字符的索引,但是如何返回特定索引处的字符呢?

0 投票
3 回答
227 浏览

c# - 如何从我一直在搜索的位置继续查找索引?

如何从我一直在搜索的位置继续查找索引?

我正在文件中搜索以查找字符的索引;然后我必须从那里继续找到下一个字符的索引。例如:字符串是“habcdefghij”

所以它应该返回“cedef”

但是第二次搜索从文件的开头开始,它将返回第一个 h 的索引而不是第二个 h:-(

0 投票
8 回答
8656 浏览

c# - IndexOf 方法在 C#/Java 中应该返回 -1 时返回 0

我的一个朋友带着这种我无法解释的奇怪行为来找我,任何洞察力的观点都将不胜感激。

我正在运行 VS 2005 (C# 2.0),以下代码显示了行为

上面的代码,打印“0”清楚地表明它应该有返回-1

这也发生在 Java 中,其中以下类显示了行为:

我正在运行 Java 1.6.0_17

0 投票
4 回答
489 浏览

c# - 当有多个字符时,如何使用 IndexOf 来选择特定字符?

当有多个字符时,如何将 IndexOf 与 SubString 一起使用来选择特定字符?这是我的问题。我想采用路径“C:\Users\Jim\AppData\Local\Temp\”并删除“Temp\”部分。只留下“C:\Users\Jim\AppData\Local\”我已经用下面的代码解决了我的问题,但这假设“Temp”文件夹实际上被称为“Temp”。有没有更好的办法?谢谢

0 投票
4 回答
11578 浏览

java - 我的对象的 ArrayList,indexOf 问题

我对 Java 的 ArrayList 有疑问。我创建了一个包含两个属性 x 和 y 的对象。现在我已经在我的 ArrayList 中加载了一些对象。问题是我不知道如何找到我正在搜索的具有 x 属性的某个对象的索引。有没有办法做到这一点?

0 投票
3 回答
3418 浏览

javascript - Internet Explorer 的数组 indexOf 实现

有很多关于如何将 indexOf 实现放入 Array 原型以便它在 Internet Explorer 下工作的解决方案,但是我偶然发现了一个问题,到目前为止我似乎在任何地方都没有解决这个问题。

使用在 MDC上达成一致的实现,我现在有以下代码存在问题:

我预计会收到 4 个警报,每个警报都包含数组的一个元素。在 Firefox 和 Chrome 中,这正是我所看到的,但是在 IE8 中,我收到了一个包含 indexOf 函数代码的附加警报。

可以做些什么来避免这种情况?