> Le 9 janv. 2016 à 09:28, ziyunfei <[email protected]> a écrit : > > $ d8 --harmony-regexp-lookbehind -e > '"123".match(/(?<=(.){3})/);print(RegExp.$1)' > 1 > > $ perl -e '"123" =~ /(?<=(.){3})/;print $1' > 3 > > Currently, V8's implementation is storing the leftmost substring in $1(and > \1) which surprised me a bit.
This is a consequence of lookbehind being implemented in V8 as traversing the string in reverse order (contrarily to Perl), and of the general rule of returning the last matched substring. I don't think it is worth to complicate the algorithm in order to "correct" that behaviour, because, for me, it is intrinsically ambiguous what match `$1` should refer to. —Claude > > Also note that in .Net, you can get all captured substrings by that capturing > group using the `.Captures` property > https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.group.captures(v=vs.110).aspx > , in this case it would be [3, 2, 1] (the order is from right to left) . _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

