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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
gmmo
  • 2,577
  • 3
  • 30
  • 56
  • Be more specific - which part of the string do you want to match? – l'L'l May 18 '15 at 04:38
  • This will require a recursive regex which supported by `regex` module of python.Are u willing to use it – vks May 18 '15 at 05:45

1 Answers1

0

May be you can try this

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

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

salvarez
  • 87
  • 1
  • 8