tags:

views:

45

answers:

1

I am using the following regular expression (from http://www.simple-talk.com/dotnet/asp.net/regular-expression-based-token-replacement-in-asp.net/)

(?<functionName>[^\$]?)\((?:(?<params>.*?)(?:,|(?=\))))*?)

it works fine, except when I what to include brackets within the parameters such as "<b>hello<b> renderHTML(""GetData(12)"") "

so I want "GetData(12)" instead I get "GetData(12".

Is there a way to ignore any matches if they are wrapped in double quotes?

+1  A: 

There are ways to ignore the parens inside of quotes but this will not solve your problem. Function calls in C# cannot be matched with a regular expression . Regular expressions cannot match nested structures such as they way both parens and < appear inside of a function call. To match these you need to use a grammar of sorts.

I while back I wrote a blog post which goes into a bit more detail about this problem

I don't mean to be avoiding the answer here. But any answer to this question will just be broken by a slightly more complex (or sometimes even simpler) function call.

JaredPar
I have read the post, it does not suggest the possible answers to the problem. Can I ask what would you do for the solution? I do not want anything too complex as there will only be few commands available.Thanks in advance.
Podge
@Podge, the only really answer is to write a full parser for the language. Or a hacky one that can properly match `(`'s and '<`'s.
JaredPar