如何提取字串中的字符
在javacript中有如下字串:
CB_TR_TS12_Project10_ID-100_EntryID_226
CB_TR_TS12_Project3_ID-100_Child1_EntryID_230
请问如何提取Project后面的数字,例如10,3
------解决方案--------------------var str= "CB_TR_TS12_Project10_ID-100_EntryID_226 ";
var kw= "Project ";
var start=str.lastIndexOf( "Project ");
var end=str.lastIndexOf( "_ID ");
var result=str.substr(start+kw.length,end-(start+kw.length));
alert(result);