1 var baseToString = require('./baseToString'),
2 isArray = require('../lang/isArray');
4 /** Used to match property names within property paths. */
5 var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
7 /** Used to match backslashes in property paths. */
8 var reEscapeChar = /\\(\\)?/g;
11 * Converts `value` to property path array if it's not one.
14 * @param {*} value The value to process.
15 * @returns {Array} Returns the property path array.
17 function toPath(value) {
22 baseToString(value).replace(rePropName, function(match, number, quote, string) {
23 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
28 module.exports = toPath;