December 23, 2014

Repeat a capturing group, pitfall in RegExp

RegExp is esoteric, known to all, but you will find it incredibly effecient when you start to get used to it. I like to use RegExp, but sometimes I tend to make mistakes, the most common of which is to repeat a capturing group. Let’s think about this. Given a string 'a=1;b=2;...;k=n', I would like to capture k, n of each pair to form an array like ['a', 1, 'b', 2, . ... Read more