B
Brantley Harris
Type this into your javascript console, you'll notice it prints out
false.
r = new RegExp("\\\\", "g"); r.test('\\') == r.test('\\');
What is going on here?
Without the global flag it will print true, as expected:
r = new RegExp("\\\\"); r.test('\\') == r.test('\\');
But with the flag it will alternate:
r = new RegExp("\\\\", "g");
r.test('\\') --> true
r.test('\\') --> false
r.test('\\') --> true
I have tried this in both Firefox and Safari. Am I going insane? Can
anyone explain this?
false.
r = new RegExp("\\\\", "g"); r.test('\\') == r.test('\\');
What is going on here?
Without the global flag it will print true, as expected:
r = new RegExp("\\\\"); r.test('\\') == r.test('\\');
But with the flag it will alternate:
r = new RegExp("\\\\", "g");
r.test('\\') --> true
r.test('\\') --> false
r.test('\\') --> true
I have tried this in both Firefox and Safari. Am I going insane? Can
anyone explain this?