1 var memoizeCapped = require('./_memoizeCapped'),
2 toString = require('./toString');
4 /** Used to match property names within property paths. */
5 var reLeadingDot = /^\./,
6 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
8 /** Used to match backslashes in property paths. */
9 var reEscapeChar = /\\(\\)?/g;
12 * Converts `string` to a property path array.
15 * @param {string} string The string to convert.
16 * @returns {Array} Returns the property path array.
18 var stringToPath = memoizeCapped(function(string) {
19 string = toString(string);
22 if (reLeadingDot.test(string)) {
25 string.replace(rePropName, function(match, number, quote, string) {
26 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
31 module.exports = stringToPath;