thank you Roly and Tim, your answers do help me a lot.
在 2012-3-13 下午8:23,"tim sebastian" <[email protected]>写道:

> 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 previous
> match."
>
> Here is another example:
> var asd = /\$[0-9]{1}/g
> /\$[0-9]{1}/g
>  asd.test("$a$1$2$3$d")
> true
>  asd.test("$a$1$2$3$d")
> true
>  asd.test("$a$1$2$3$d")
> true
>  asd.test("$a$1$2$3$d")
> false
>
> Hope that helps
>
> On Tue, Mar 13, 2012 at 9:45 AM, Yi Tan <[email protected]> wrote:
>
>> 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)
>> //output: true
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to