For a string such as the following:
`const someConst= {
name: 'someName',
someProp: {
somePropOfSomeProp: 'value'
}};`
How would i match the value of someProp ?
Assumptions:
- the property name is always known
someProp - the property value would always be of type object
- The
somePropobject cannot have nested objects. It will be flat.
I am using Javascript regex to solve this problem.
To provide more context to the type of structure we can expect for someProp. This is basically supposed to be the bindings property for angular components. So expected values could be the following:
bindings: {
someBinding: '=',
someOtherBinding: '@'
}
OR the props for bindings may not be on the same line. So they could be:
bindings: { someBinding: '=', someOtherBinding: '@' }
So basically i would need:
{
someBinding: '=',
someOtherBinding: '@'
}
somePropobject? Is the data from a safe source? If both answers are "yes", I'd be inclined to use the JS engine to evaluate the data.constdecl.