JavaScript有两种方式创建一个正则表达式:
第一种方式是直接通过/正则表达式/
写出来,第二种方式是通过new RegExp('正则表达式')
创建一个RegExp对象。
如:
var
re1 = /ABC\-001/;
var
re2 =
new
RegExp(
'ABC\\-001'
);
想要实现功能:从字符串中以多数组方式解析字符串
字符串:"adfsdf:a=1,b=2,c=3,d=-1.3;0;adfasdf"
结果:

代码:
controlPara.preControlLogic ="adfsdf:a=1,b=2,c=3,d=-1.3;0;adfasdf" var resultS2;
var patt = new RegExp("([A-Za-z0-9_.]+)=([0-9.-]+)","g");
while ((resultS2 = patt.exec(controlPara.preControlLogic)) !== null) {
console.log(resultS2);
}