If I have a JavaScript expression and I want to replace all instances of a particular property with a function instead. For example:
foo => getFoo()
a.b.foo => getFoo(a.b)
a.foo.b => getFoo(a).b
a.foo.foo => getFoo(getFoo(a))
a.foo.b.foo => getFoo(getFoo(a).b)
a.foo+b.foo||c.foo => getFoo(a)+getFoo(b)||getFoo(c)
a(b.foo) => a(foo(b))
I will need to have a check for the characters which would mean the end or start of a particular variable which are ' ', '|', '&', '(', ')', ',', '+', '-', '=', '<', '>'
If I get to the string 'foo' I then need to move everything from the character after one of those listed above to the inside of getFoo().
Not sure how this can be implemented or if another method other than regex would be a better approach?