网上文档写的,太tm绕了~~
<script> var str = "<a target='_blank' href='+basePath+/workflow/resource/read?processDefinitionId=${object[0].id}&resourceType=xml'>${object[0].resourceName }</a>"; var patt = new RegExp("\\$\\{(.*?)\\}","g");
var result; while ((result = patt.exec(str)) != null) { document.write(result.index); //匹配的开始下标 document.write("--"); document.write(result.length); //result数组的长度 document.write("--"); document.write(result[0]); //匹配上的字符串 document.write("--"); document.write(result[1]); //分组1的内容 document.write("<br />"); } document.write("<hr/>"); var array = str.match(patt); for(var i=0;i<array.length;i++){ document.write("<li>"+array[i]); } </script>
|