[nodejs] RegXp.test() behaves inconsistently

2012-03-13 Thread Yi Tan
var reg = /[^\$]*\$([^\|]*)\|?(.*)/g var a = '$3ec05baeef7' reg.test(a) //output: true reg.test(a) //output: false reg.test(a) //output: true reg.test(a) //output: false reg.test(a) //output: true reg.test(a) //output: false reg.test(a) //output: true reg.test(a) //output: false reg.test(a)

Re: [nodejs] RegXp.test() behaves inconsistently

2012-03-13 Thread tim sebastian
Ha funny thing, didnt knew about it but it seems legit. According to MDN ( https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp/test ) As with exec (or in combination with it), test called multiple times on the same global regular expression instance will advance past the

Re: [nodejs] RegXp.test() behaves inconsistently

2012-03-13 Thread Yi Tan
thank you Roly and Tim, your answers do help me a lot. 在 2012-3-13 下午8:23,tim sebastian tim.sebast...@googlemail.com写道: Ha funny thing, didnt knew about it but it seems legit. According to MDN ( https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp/test ) As with exec