如何得到相同字符串的位置 如内容 abcdadde 我要得到a在内容里的各个位置,请问如何做啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>var src = " abcdadde";var re = /a/gi;var arr;while ((arr = re.exec(src)) != null){ document.write(arr.index + " - "+ arr.lastIndex + " : " + arr + "<br>");}</script> string strIndex1 = ""; string strIndex2 = ""; //Regex reg = new Regex("\b"+strChar+"\b"); Regex reg = new Regex(strChar); Match match = reg.Match(s); while(match.Success) { strIndex1 += s.LastIndexOf(match.Groups[0].ToString()) + strChar; strIndex2 += s.IndexOf(match.Groups[0].ToString()) + strChar; } return strIndex1;不行 //字符所在位置int b=Form1.str.IndexOf("a",0,str.Length);//字符"a"在字符串中第一次出现的位置int x=b+1;while(true){int c=Form1.str.IndexOf("a",x,str.Length-x);//判断下一个查找的字符的位置。if(c==-1)//如果该字符(a)在剩下的字符串中不存在{ break;}x=b+1+c;if(x>str.Length)//当所有字符串都搜索完毕{ break;}} 有没有控件 关于dotnetCHARTING的使用,请教!! 求解 gridview操作的问题 asp.net中用VB 可以实现浮动信息提示框吗? 关于Excel的导入导出的问题。在线求助! ■■■■ 大家来帮帮忙~~ ■■■■ 有请各位仁兄帮忙,在ASP.NET中如何连接DB2数据库!!!!!!!!!!????? 如何让动太插入的超链接居中? 我的dreamweaver mx不能保存字体的修改,有什么办法解决?? 远程数据库导入的问题! SQL 语句使用参数时,造成错误
var src = " abcdadde";
var re = /a/gi;
var arr;
while ((arr = re.exec(src)) != null)
{
document.write(arr.index + " - "+ arr.lastIndex + " : " + arr + "<br>");
}
</script>
string strIndex2 = "";
//Regex reg = new Regex("\b"+strChar+"\b");
Regex reg = new Regex(strChar);
Match match = reg.Match(s);
while(match.Success)
{
strIndex1 += s.LastIndexOf(match.Groups[0].ToString()) + strChar;
strIndex2 += s.IndexOf(match.Groups[0].ToString()) + strChar;
}
return strIndex1;不行
int b=Form1.str.IndexOf("a",0,str.Length);//字符"a"在字符串中第一次出现的位置
int x=b+1;
while(true)
{
int c=Form1.str.IndexOf("a",x,str.Length-x);//判断下一个查找的字符的位置。
if(c==-1)//如果该字符(a)在剩下的字符串中不存在
{
break;
}
x=b+1+c;
if(x>str.Length)//当所有字符串都搜索完毕
{
break;
}
}