0

I have the following line

(textMsg).Style.set_BackgroundColor(Color.FromArgb(0, 0, 0));

and what I want to get is

(textMsg).Style.BackgroundColor = Color.FromArgb(0, 0, 0);

i tried with the following regEx pattern but with no luck

set_(.*)\((([^()]*|(?R))*)\)

i would appreciate any suggestion.

Thanks

profanis
  • 2,741
  • 3
  • 39
  • 49
  • `(@R)` is a Perl/PCRE-specific recurse-whole-pattern expression. .NET also handles recursion but uses a different syntax. See: [regex embedded {{ matching](http://stackoverflow.com/a/6002694/433790) and substitute parentheses for curly braces. – ridgerunner Aug 28 '13 at 14:29

1 Answers1

0

You could try this instead:

set_([^(]*)\((.*)\)

This captures the property name after set_ in group $1 and anything between the ( and ) of the method call into group `$2, so you can use a replacement string like this:

$1 = $2

Regex 101 Demo

Your expression is invalid and won't compile because you have unbalanced parentheses and un-recongnized tokens.

Ibrahim Najjar
  • 19,178
  • 4
  • 69
  • 95