按照你的要求编写的Javascript语言的匹配符号中间数据的程序如下
<script type=text/javascript>var str='"tag":"0","hpmax":"330","actortype":"1"\r\n"tag":"1","hpmax":"340","actortype":"1"\r\n"tag":"2","hpmax":"350","actortype":"1"\r\n"tag":"3","hpmax":"360","actortype":"1"\r\n"tag":"4","hpmax":"370","actortype":"1"'
var regex=/"hpmax"\:"([0-9]+)"/ig
var result
while((result=regex.exec(str))!=null)
alert(result[1])
</script>
运行结果
330
340
350
360
370
这个完全不需要用到正则,直接split字符串就搞定了
var str = '2013-05-05&2013-05-06&2013-05-01'var arr = str.split('&')
// 如果硬要用正则
// arr = str.split(/&/)
console.log(arr)