日期:2014-05-16 浏览次数:20478 次
var s='01财务部#1#,22设备部#2#,武保部#3#,运输部#4#';
var a=[];
s.replace(/#(\d+)#/g,function ($_,$1){a.push($1)});
alert(a);
'01财务部#1#,22设备部#2#,武保部#3#,运输部#4#,'.replace(/([^#]+#{1})(\d+)(#{0,1})([,]{0,1})/g,"$2$4")
<script type="text/javascript">
var str="01财务部#1#,22设备部#2#,武保部#3#,运输部#4#";
var b = str.match(/#(\d+)#/g).join(",").replace(/#/g,"");
</script>