diff --git a/lib/parse.js b/lib/parse.js index 97387a6a..fcf0355a 100755 --- a/lib/parse.js +++ b/lib/parse.js @@ -80,12 +80,12 @@ var parseKeys = function parseKeys(givenKey, val, options) { } // Transform dot notation to bracket notation - var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey; + var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; // The regex chunks - var parent = /^([^\[\]]*)/; - var child = /(\[[^\[\]]*\])/g; + var parent = /^([^[\]]*)/; + var child = /(\[[^[\]]*])/g; // Get the parent @@ -111,7 +111,7 @@ var parseKeys = function parseKeys(givenKey, val, options) { var i = 0; while ((segment = child.exec(key)) !== null && i < options.depth) { i += 1; - if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) { + if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|]/g, ''))) { if (!options.allowPrototypes) { continue; }