Does that imply that Javascript has different capture semantics than perl?
No. It is just that match() returns the matched substrings, not the captured substrings. If //g in a list context could be told to return the matched substrings (what it does when there are no capturing parens), then the same solution would work in Perl.
A better JavaScript solution is actually: "ZBBBCZZ".match(/(.)\1*/g). No need for the second set of parens.
- tye
In reply to Re^5: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...) (js)
by tye
in thread Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
by eyepopslikeamosquito
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |