summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/string-regexp-capture-groups.js
blob: 0fc1bb8a11ab4d425390c51fa5d7c9bdf3112ca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"abcdefg".match(/(x)y(z)/g);
assertEq(RegExp.$1, "");

assertEq("abcdef".match(/a(b)cd/g)[0], "abcd");
assertEq(RegExp.$1, "b");
assertEq(RegExp.$2, "");

"abcdef".match(/(a)b(c)/g);
assertEq(RegExp.$1, "a");
assertEq(RegExp.$2, "c");
assertEq(RegExp.$3, "");

"abcabdabe".match(/(a)b(.)/g);
assertEq(RegExp.$1, "a");
assertEq(RegExp.$2, "e");

"abcdefg".match(/(x)y(z)/g);
assertEq(RegExp.$1, "a");    //If there's no match, we don't update the statics.

"abcdefg".match(/(g)/g);
assertEq(RegExp.$1, "g");