I'm trying to regex search for += operator matches inside a function named OnDisabled() in Rider (JetBrains).
Regex I have so far: /OnDisable \(.*?\) \{(?=.*?)[^{}]+\}/gm
but it matches everything inside the curly brackets right now.
Example code I have for testing is as follows:
private void OnEnable () {
someEvent.OnEventRaised += MyFunction; // Ignored
someOtherEvent.OnEventRaised += MyFunction2; // Ignored
anotherEvent.OnEventRaised += MyFunction3; // Ignored
}
private void OnDisable () {
someEvent.OnEventRaised += MyFunction; // <-- Should be found #1
someOtherEvent.OnEventRaised -= MyFunction2; // Ignored
anotherEvent.OnEventRaised += MyFunction3; // <-- Should also be found #2
}
Additional information:
- Function/code style is always
OnDisable () {
- Indentation can vary inside the function
- Only want to find any
+=
operator inside the function, rest is not important