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