Encoding between GB2312 and UTF-8 >>
<< 猪是怎样死的(猪.com倒闭篇)
Add brackets to RegExp as necessary

Author Zhou Renjian Create@ 2004-11-12 09:01
whizz Note icon
var regexp = new RegExp("^(" + formatList[i + i] + ")$");

Brackets is every important, or it will come out unexpect results. For example, for ([1-9]\d(\.\d\d?)?)|(\d(\.\d\d?)?)|(100(\.00?)?),

var regexp = /^([1-9]\d(\.\d\d?)?)|(\d(\.\d\d?)?)|(100(\.00?)?)$/;
alert(regexp.test("27.8d"));

var regexp = /^(([1-9]\d(\.\d\d?)?)|(\d(\.\d\d?)?)|(100(\.00?)?))$/;
alert(regexp.test("27.8d"));

will come out with true and false, in which the former is incorrect!
本记录所在类别:
本记录相关记录: