let rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g ; let reEscapeChar = /\\(\\)?/g ; export function stringToPath ( string ) { let result = [ ] ; if ( string . charCodeAt ( 0 ) === 46 ) { result . push ( '' ) ; } string . replace ( rePropName , ( match , number , quote , subString ) => { result . push ( quote ? subString . replace ( reEscapeChar , '$1' ) : number || match ) ; } ) ; return result ; }