it works:) please post an answer, so I can choose you. Does it mean that without 'g' it just finds the first match only?
– Sergej FominJul 26 '17 at 10:30
It finds the first occurence of `/\[|\]/`, which is `[`. I generally won’t post answers without searching for duplicate targets first.
– Sebastian SimonJul 26 '17 at 10:31
`var i = '[0]';
i.replace(/\[|\]/g, '');` will output '0' I just added if somebody becomes confused about where to add 'g' flag.
– user2906838Jul 26 '17 at 10:33