I have a string that looks like this:
const str = "income[1].selected"
I would like to get a 3 separate elements by splitting this string by [
, ]
, and .
characters.
I have tried to do it by:
field.split(/[[\].]/)
But, that gives me 4 elements:
(4) ['income', '1', '', 'selected']
What kind of regex do I need to avoid empty string element?