c# - Regex, match string ending with ) and ignore any () inbetween -


this question has answer here:

i want select part of string, problem last character want select can have multiple occurrences.

i want select 'aggregate(' , end @ matching ')', () in between can ignored.

examples:

string: substr(aggregate(subquery, sum, [model].remark * [object].shortname + 10), 0, 1)
should return: aggregate(subquery, sum, [model].remark * [object].shortname + 10)

string: substr(aggregate(subquery, sum, [model].remark * ([object].shortname + 10)), 0, 1)
should return: aggregate(subquery, sum, [model].remark * ([object].shortname + 10))

string: substr(aggregate(subquery, sum, ([model].remark) * ([object].shortname + 10) ), 0, 1)
should return: aggregate(subquery, sum, ([model].remark) * ([object].shortname + 10) )

is there way solve regular expression? i'm using c#.

this little ugly, use like

aggregate\(([^()]+|\(.*?\))*\) 

it passes tests, can match 1 level of nested parentheses.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -