问题描述
解决方案
解决方案二:
var idx = str.indexOf("icon_skill");
var result = str.substring(idx,str.length-3);
调试一下,
解决方案三:
不太清楚你要取哪段字符串
解决方案四:
<html>
<head>
<title>使用RegExp提取字符串</title>
<script language="javascript" type="text/javascript">
var reg = /icon_skill_.*_png/;
var str1 = 'this.ui("iconSpr").startLoad1("icon_skill_"+this._model.getValue("cId")+"_"+"icon_skill"+d["idk"]+"_png")';
var str2 = 'this.ui("iconSpr").startLoad1("icon_skill_1"+d["idk"]+"_png")';
alert(matches(reg,str1));
alert(matches(reg,str2));
function matches(reg,str){
var matchesString = reg.exec(str);
return matchesString;
}
</script>
</head>
<body>
</body>
</html>
解决方案五:
正则表达式吧,很简单的
时间: 2025-01-19 07:28:02