Click here to Skip to main content
15,303,522 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Can not get why my Regex class can not instantiate. The regular expression seems to be fine, but i'm getting error message when calling "BuildStructure":

System.ArgumentException : parsing "[(.*?;)(([(if)(while)(for)]).*?\(.*?\){({.*?})*?})]" - Too many )'s.

Here is the code:
class CodeStructureBuilder
private const String REGULAR_EXPRESSION =

public CodeStructureBuilder() {}

public void BuildStructure()
    Regex regex = new Regex(REGULAR_EXPRESSION);

1 solution

You either have an extra backslash:
or one too few:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900