查出来的一个字段内容是一段脚本,内容类似如下:
select id from tables where name = #name# and type = #type#
现在想将里面的参数拿出来放到另外一个字段里面去,多个参数用“,”隔开,
如上面的参数字段内容就是:name,type
参数个数不一定,可能没有,没有就返回“-”,但一定是#之间的。
想写个函数,将这段需要解析的脚本内容作为参数传进去,然后返回想要的结果。
wait online!!!
谢谢了
给你个js版本的,别的语言就是API换一下就行
[code="js"]
var arr = []
var s = 'select id from tables where name = #name# and type = #type# '
var reg = /#([^#]+)#/g
var item
while(item = reg.exec(s)) arr.push(item[1]);
arr
[ 'name', 'type' ]
[/code]