0

I'd like to extract all the parameters of these methods with a regex. However, due to the SAL markings, I can't get the nested parenthesis to work correctly. I have these string to parse (multi-lined):

STDMETHOD_(void, Method1)(
_Out_writes_to_(gradientStopsCount, _Inexpressible_("Retrieved through GetGradientStopCount") ) D2D1_GRADIENT_STOP *gradientStops,
UINT32 gradientStopsCount) CONST PURE;

STDMETHOD_(void, Method1)(
_Out_writes_to_(gradientStopsCount, _Inexpressible_("Retrieved through GetGradientStopCount") ) D2D1_GRADIENT_STOP *gradientStops,
UINT32 gradientStopsCount) CONST PURE;

I tried this:

\(((.|\n|\r)*?)\)

But because there are nested parenthesis for the parameters, it won't match properly. Indeed I'd like to extract everything including nested parenthesis of a string like

MyFunc(...anything in here including more parenthesis...)

Is is doable with one single regex?

2
  • Be more specific - which part of the string do you want to match? Commented May 18, 2015 at 4:38
  • This will require a recursive regex which supported by regex module of python.Are u willing to use it Commented May 18, 2015 at 5:45

1 Answer 1

0

May be you can try this

".*?)((.+)).+\;" with s flag to match among several lines.

Sample: https://regex101.com/r/fJ4cN3/1

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.