showing results for - "rename object keys using regexp"
Carolina
10 Oct 2016
1const result = data.map(datum => Object.assign(...Object
2    .keys(datum)
3    .map(key => ({ [key.replace(/[.|&;$%@%"<>+]/g, '')]: datum[key] }))
4));
Julia
27 Sep 2016
1data = [
2  {someKey:   1},
3  {some0Key:  1},
4  {some1Key:  1,
5    some2Key:  1},
6  {some3Key:  1,
7    some4Key:  1,
8    some5Key:  1,
9    some6Key:  1,
10    some7Key:  1,
11    some8Key:  1,
12    some9Key:  1,
13    some10Key: 1,
14  },
15  {some11Key: 1,
16    some12Key: 1,
17    some13Key: 1,
18    some14Key: 1,
19    some15Key: 1,}
20];
21result = data.map(datum => Object.assign(...Object
22    .keys(datum)
23    .map(key => ({ [key.replace(/some/g, 'bum')]: datum[key] }))
24));