Updates:
Status: WorkingAsIntended
Comment #2 on issue 3181 by [email protected]: Regex behave wrong
http://code.google.com/p/v8/issues/detail?id=3181
Working as intended. The /g flag makes the regexp sticky. For
Regexp.prototype.test this means that it continues at the index where it
started, even if you pass a different subject string. On match failure the
index is reset to 0. Consider this:
print = function(x) { console.log(x) };
re=/^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,30}[a-zA-Z0-9_.$-]?$/g
print(re.test('a'))
print(re.lastIndex);
print(re.test('_a'))
print(re.lastIndex);
print(re.test('__a'))
print(re.lastIndex);
print(re.test('___a'))
print(re.lastIndex);
Result is (on both Firefox and Chrome):
true
1
false
0
true
3
false
0
Remove that /g flag if you don't want this behavior.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.